Exemplo n.º 1
0
    def test_is_requesting_update_when_other_node_arrived(self):
        node = {
            'type': NodeType.EXCALL,
        }

        config_source = ConfigCommentSource()
        is_requesting_update = config_source.is_requesting_update(node)

        self.assertFalse(is_requesting_update, 'Expected false was returned')
Exemplo n.º 2
0
    def test_is_requesting_update_when_other_node_arrived(self):
        node = {
            'type': NodeType.EXCALL,
        }

        config_source = ConfigCommentSource()
        is_requesting_update = config_source.is_requesting_update(node)

        self.assertFalse(is_requesting_update, 'Expected false was returned')
Exemplo n.º 3
0
    def test_is_requesting_update_when_config_comment_arrived(self):
        node = {
            'type': NodeType.COMMENT,
            'str': ' vint: -Policy1 +Policy2',
        }

        config_source = ConfigCommentSource()
        is_requesting_update = config_source.is_requesting_update(node)

        self.assertTrue(is_requesting_update, 'Expected true was returned')
Exemplo n.º 4
0
    def test_is_requesting_update_when_just_comment_arrived(self):
        node = {
            'type': NodeType.COMMENT,
            'str': ' Lorem ipsum',
        }

        config_source = ConfigCommentSource()
        is_requesting_update = config_source.is_requesting_update(node)

        self.assertFalse(is_requesting_update, 'Expected false was returned')
Exemplo n.º 5
0
    def test_is_requesting_update_when_just_comment_arrived(self):
        node = {
            'type': NodeType.COMMENT,
            'str': ' Lorem ipsum',
        }

        config_source = ConfigCommentSource()
        is_requesting_update = config_source.is_requesting_update(node)

        self.assertFalse(is_requesting_update, 'Expected false was returned')
Exemplo n.º 6
0
    def test_is_requesting_update_when_config_comment_arrived(self):
        node = {
            'type': NodeType.COMMENT,
            'str': ' vint: -Policy1 +Policy2',
        }

        config_source = ConfigCommentSource()
        is_requesting_update = config_source.is_requesting_update(node)

        self.assertTrue(is_requesting_update, 'Expected true was returned')
Exemplo n.º 7
0
    def test_update_by_node_by_no_switches(self):
        node = {
            'type': NodeType.COMMENT,
            'str': ' vint:',
        }

        expected_config_dict = {'policies': {}}

        config_source = ConfigCommentSource()
        config_source.update_by_node(node)

        self.assertConfigDict(config_source, expected_config_dict)
Exemplo n.º 8
0
    def test_update_by_node_by_no_switches(self):
        node = {
            'type': NodeType.COMMENT,
            'str': ' vint:',
        }

        expected_config_dict = {
            'policies': {}
        }

        config_source = ConfigCommentSource()
        config_source.update_by_node(node)

        self.assertConfigDict(config_source, expected_config_dict)
Exemplo n.º 9
0
    def test_update_by_node_by_single_switch(self):
        node = {
            'type': NodeType.COMMENT,
            'str': ' vint: -Policy1',
        }

        expected_config_dict = {
            'policies': {
                'Policy1': {
                    'enabled': False,
                },
            }
        }

        config_source = ConfigCommentSource()
        config_source.update_by_node(node)

        self.assertConfigDict(config_source, expected_config_dict)
Exemplo n.º 10
0
    def __init__(self, policy_set, config_dict_global):
        self._parser = self.build_parser()
        self._policy_set = policy_set

        self._config_comment_source = ConfigCommentSource()
        self._config = self._decorate_config(config_dict_global,
                                             self._config_comment_source)

        self._listeners_map = {}
Exemplo n.º 11
0
    def test_update_by_node_by_single_switch(self):
        node = {
            'type': NodeType.COMMENT,
            'str': ' vint: -Policy1',
        }

        expected_config_dict = {
            'policies': {
                'Policy1': {
                    'enabled': False,
                },
            }
        }

        config_source = ConfigCommentSource()
        config_source.update_by_node(node)

        self.assertConfigDict(config_source, expected_config_dict)
Exemplo n.º 12
0
    def test_get_config_dict(self):
        expected_config_dict = {
            'policies': {
                'Policy1': {
                    'enabled': False,
                },
                'Policy2': {
                    'enabled': True,
                },
            }
        }

        node = {
            'type': NodeType.COMMENT,
            'str': ' vint: -Policy1 +Policy2',
        }

        config_source = ConfigCommentSource()
        config_source.update_by_node(node)
        self.assertConfigDict(config_source, expected_config_dict)
Exemplo n.º 13
0
    def test_get_config_dict(self):
        expected_config_dict = {
            'policies': {
                'Policy1': {
                    'enabled': False,
                },
                'Policy2': {
                    'enabled': True,
                },
            }
        }

        node = {
            'type': NodeType.COMMENT,
            'str': ' vint: -Policy1 +Policy2',
        }

        config_source = ConfigCommentSource()
        config_source.update_by_node(node)
        self.assertConfigDict(config_source, expected_config_dict)