summaryrefslogtreecommitdiff
path: root/src/leap/eip/tests/test_checks.py
blob: 53f8dc6c8fea579db6fb15f221b8aa1c402e2acb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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()