summaryrefslogtreecommitdiff
path: root/src/leap/eip
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-08-27 07:35:00 +0900
committerkali <kali@leap.se>2012-08-27 07:35:00 +0900
commite896190d159342d9819f0ad6f11fe01deb8eb9e5 (patch)
tree7bd9bdcda57b38baaf9e3ed8d28441617e6386b3 /src/leap/eip
parent10292cac27bc2f10e2b5768c84091a73105bc495 (diff)
add stubs for eip.checks
will handle pre-init sanity checks for eip connection. some of this will actually end in more general leap-checks, but let's keep it alltogether by now.
Diffstat (limited to 'src/leap/eip')
-rw-r--r--src/leap/eip/checks.py50
-rw-r--r--src/leap/eip/tests/test_checks.py54
2 files changed, 104 insertions, 0 deletions
diff --git a/src/leap/eip/checks.py b/src/leap/eip/checks.py
new file mode 100644
index 00000000..bb588cf7
--- /dev/null
+++ b/src/leap/eip/checks.py
@@ -0,0 +1,50 @@
+import logging
+logger = logging.getLogger(name=__name__)
+
+
+class EIPChecker(object):
+ """
+ Executes all tests needed
+ to ensure a EIPConnection
+ can be sucessful
+ """
+ def __init__(self):
+ pass
+
+ def do_all_checks(self, checker=None):
+ """
+ just runs all tests in a row.
+ will raise if some error encounter.
+ catching those exceptions is not
+ our responsibility at this moment
+ """
+ if not checker:
+ checker = self
+
+ # let's call all tests
+ # needed for a sane eip session.
+
+ checker.dump_default_eipconfig()
+ checker.check_is_there_default_provider()
+ checker.fetch_definition()
+ checker.fetch_eip_config()
+ checker.check_complete_eip_config()
+ checker.ping_gateway()
+
+ def dump_default_eipconfig(self):
+ raise NotImplementedError
+
+ def check_is_there_default_provider(self):
+ raise NotImplementedError
+
+ def fetch_definition(self):
+ raise NotImplementedError
+
+ def fetch_eip_config(self):
+ raise NotImplementedError
+
+ def check_complete_eip_config(self):
+ raise NotImplementedError
+
+ def ping_gateway(self):
+ raise NotImplementedError
diff --git a/src/leap/eip/tests/test_checks.py b/src/leap/eip/tests/test_checks.py
new file mode 100644
index 00000000..53f8dc6c
--- /dev/null
+++ b/src/leap/eip/tests/test_checks.py
@@ -0,0 +1,54 @@
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
+from mock import Mock
+
+from leap.eip import checks as eip_checks
+from leap.testing.basetest import BaseLeapTest
+
+
+class EIPCheckTest(BaseLeapTest):
+
+ __name__ = "eip_check_tests"
+
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ def test_checker_should_implement_check_methods(self):
+ checker = eip_checks.EIPChecker()
+
+ self.assertTrue(hasattr(checker, "dump_default_eipconfig"),
+ "missing meth")
+ self.assertTrue(hasattr(checker, "check_is_there_default_provider"),
+ "missing meth")
+ self.assertTrue(hasattr(checker, "fetch_definition"), "missing meth")
+ self.assertTrue(hasattr(checker, "fetch_eip_config"), "missing meth")
+ self.assertTrue(hasattr(checker, "check_complete_eip_config"),
+ "missing meth")
+ self.assertTrue(hasattr(checker, "ping_gateway"), "missing meth")
+
+ def test_checker_should_actually_call_all_tests(self):
+ checker = eip_checks.EIPChecker()
+
+ mc = Mock()
+ checker.do_all_checks(checker=mc)
+ self.assertTrue(mc.dump_default_eipconfig.called, "not called")
+ self.assertTrue(mc.check_is_there_default_provider.called,
+ "not called")
+ self.assertTrue(mc.fetch_definition.called,
+ "not called")
+ self.assertTrue(mc.fetch_eip_config.called,
+ "not called")
+ self.assertTrue(mc.check_complete_eip_config.called,
+ "not called")
+ self.assertTrue(mc.ping_gateway.called,
+ "not called")
+
+
+if __name__ == "__main__":
+ unittest.main()