init comit

This commit is contained in:
stubbfel
2018-05-11 20:18:41 +02:00
commit ce31165177
15 changed files with 406 additions and 0 deletions

0
tests/__init__.py Normal file
View File

0
tests/api/__init__.py Normal file
View File

View File

View File

@@ -0,0 +1,16 @@
import unittest
from mmgs108.api.http.sap import Sap
from mmgs108.ui.kivy.app import Gs108App
class TestSap(unittest.TestCase):
def test_generate_url(self):
sap = Sap("foo")
self.assertEqual("http://foo/bar", sap.generate_url("bar"))
def test_runServer(self):
Gs108App(["10.0.0.254"]).run()
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,25 @@
import unittest
import random
from mmgs108.api.http.sap import Sap
from mmgs108.api.http.session import Session
from mmgs108.api.http.vlan_table import VLanTable
class TestVLanTable(unittest.TestCase):
def test_get_vlan_table(self):
sap = Sap("10.0.0.254")
vlan_id = random.randrange(1, 4095)
port_key = "port{}".format(random.randrange(2, 8))
with Session(sap, "password") as session1:
table = VLanTable(session1)
table[port_key] = vlan_id
self.assertEqual(str(vlan_id), table[port_key])
with Session(sap, "password") as session2:
table = VLanTable(session2)
self.assertEqual(str(vlan_id), table[port_key])
if __name__ == '__main__':
unittest.main()