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')
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')
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')
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)
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)
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)
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 = {}
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)