summaryrefslogtreecommitdiff
path: root/tests/test_vpn_management.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-07-22 21:10:15 -0700
committerkali <kali@leap.se>2012-07-22 21:10:15 -0700
commitc46d8da153ac658c8bd145376e22b1218db1090a (patch)
tree0943a4a866d9f3b1bc590c1c23f810ca13635f9e /tests/test_vpn_management.py
initial import
Diffstat (limited to 'tests/test_vpn_management.py')
-rw-r--r--tests/test_vpn_management.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_vpn_management.py b/tests/test_vpn_management.py
new file mode 100644
index 00000000..d8a0314b
--- /dev/null
+++ b/tests/test_vpn_management.py
@@ -0,0 +1,42 @@
+import unittest
+import sys
+import time
+
+from eip_client.mocks.manager import get_openvpn_manager_mocks
+
+
+class VPNManagerTests(unittest.TestCase):
+
+ def setUp(self):
+ self.manager = get_openvpn_manager_mocks()
+
+ #
+ # tests
+ #
+
+ def test_status_command(self):
+ ret = self.manager.status()
+ #print ret
+
+ def test_connection_state(self):
+ ts, status, ok, ip, remote = self.manager.get_connection_state()
+ self.assertTrue(status in ('CONNECTED', 'DISCONNECTED'))
+ self.assertTrue(isinstance(ts, time.struct_time))
+
+ def test_status_io(self):
+ when_ts, counters = self.manager.get_status_io()
+ self.assertTrue(isinstance(when_ts, time.struct_time))
+ self.assertEqual(len(counters), 5)
+ self.assertTrue(all(map(lambda x: x.isdigit(), counters)))
+
+
+def test():
+ suite = unittest.TestSuite()
+ for cls in (VPNManagerTests,):
+ suite.addTest(unittest.makeSuite(cls))
+ runner = unittest.TextTestRunner(sys.stdout, verbosity=2,
+ failfast=False)
+ result = runner.run(suite)
+
+if __name__ == "__main__":
+ test()