summaryrefslogtreecommitdiff
path: root/src/leap/eip/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/eip/tests')
-rw-r--r--src/leap/eip/tests/test_checks.py35
-rw-r--r--src/leap/eip/tests/test_config.py4
2 files changed, 33 insertions, 6 deletions
diff --git a/src/leap/eip/tests/test_checks.py b/src/leap/eip/tests/test_checks.py
index 53f8dc6c..ea2b3d15 100644
--- a/src/leap/eip/tests/test_checks.py
+++ b/src/leap/eip/tests/test_checks.py
@@ -1,11 +1,15 @@
+import json
try:
import unittest2 as unittest
except ImportError:
import unittest
+import os
from mock import Mock
-from leap.eip import checks as eip_checks
+from leap.base import config as baseconfig
+from leap.eip import checks as eipchecks
+from leap.eip import constants as eipconstants
from leap.testing.basetest import BaseLeapTest
@@ -19,10 +23,12 @@ class EIPCheckTest(BaseLeapTest):
def tearDown(self):
pass
+ # test methods are there, and can be called from run_all
+
def test_checker_should_implement_check_methods(self):
- checker = eip_checks.EIPChecker()
+ checker = eipchecks.EIPChecker()
- self.assertTrue(hasattr(checker, "dump_default_eipconfig"),
+ self.assertTrue(hasattr(checker, "check_default_eipconfig"),
"missing meth")
self.assertTrue(hasattr(checker, "check_is_there_default_provider"),
"missing meth")
@@ -33,11 +39,11 @@ class EIPCheckTest(BaseLeapTest):
self.assertTrue(hasattr(checker, "ping_gateway"), "missing meth")
def test_checker_should_actually_call_all_tests(self):
- checker = eip_checks.EIPChecker()
+ checker = eipchecks.EIPChecker()
mc = Mock()
- checker.do_all_checks(checker=mc)
- self.assertTrue(mc.dump_default_eipconfig.called, "not called")
+ checker.run_all(checker=mc)
+ self.assertTrue(mc.check_default_eipconfig.called, "not called")
self.assertTrue(mc.check_is_there_default_provider.called,
"not called")
self.assertTrue(mc.fetch_definition.called,
@@ -49,6 +55,23 @@ class EIPCheckTest(BaseLeapTest):
self.assertTrue(mc.ping_gateway.called,
"not called")
+ # test individual check methods
+
+ def test_dump_default_eipconfig(self):
+ checker = eipchecks.EIPChecker()
+ # no eip config (empty home)
+ eipconfig = baseconfig.get_config_file(eipconstants.EIP_CONFIG)
+ self.assertFalse(os.path.isfile(eipconfig))
+ checker.check_default_eipconfig()
+ # we've written one, so it should be there.
+ self.assertTrue(os.path.isfile(eipconfig))
+ with open(eipconfig, 'rb') as fp:
+ deserialized = json.load(fp)
+ self.assertEqual(deserialized,
+ eipconstants.EIP_SAMPLE_JSON)
+ # TODO: when new JSONConfig class is in place, we shold
+ # run validation methods.
+
if __name__ == "__main__":
unittest.main()
diff --git a/src/leap/eip/tests/test_config.py b/src/leap/eip/tests/test_config.py
index ed9fe270..fac4729d 100644
--- a/src/leap/eip/tests/test_config.py
+++ b/src/leap/eip/tests/test_config.py
@@ -81,6 +81,10 @@ class EIPConfigTest(BaseLeapTest):
self.assertEqual(command, 'openvpn')
self.assertEqual(args, self.get_expected_openvpn_args())
+ # XXX TODO:
+ # - should use touch_exec to plant an "executabe" in the path
+ # - should check that "which" for openvpn returns what's expected.
+
if __name__ == "__main__":
unittest.main()