def test_find_violations(self, mock_dao): root = self._pickle_load('expected_root_with_rules.pickle') scanner = groups_scanner.GroupsScanner({}, {}, '', '') all_violations = scanner._find_violations(root) self.assertEquals(3, len(all_violations)) for violation in all_violations: self.assertEquals('*****@*****.**', violation.member_email)
def test_build_group_tree(self, mock_dao): mock_dao.get_all_groups.return_value = fake_data.ALL_GROUPS mock_dao.get_group_members.side_effect = fake_data.ALL_GROUP_MEMBERS scanner = groups_scanner.GroupsScanner({}, {}, '', '') scanner.dao = mock_dao root = scanner._build_group_tree('') self.assertEquals(fake_data.EXPECTED_MEMBERS_IN_TREE, self._render_ascii(root, 'member_email'))
def test_apply_rule(self, mock_dao): root = self._pickle_load('expected_root_without_rules.pickle') with open('tests/scanner/test_data/fake_group_rules.yaml', 'r') as f: rules = yaml.load(f) scanner = groups_scanner.GroupsScanner({}, {}, '', '') root_with_rules = scanner._apply_all_rules(root, rules) self.assertEquals(fake_data.EXPECTED_MEMBERS_IN_TREE, self._render_ascii(root_with_rules, 'member_email')) self.assertEquals(fake_data.EXPECTED_RULES_IN_TREE, self._render_ascii(root_with_rules, 'rules'))