From 9e5f69dc5b99103c30b0fd2cf8368c7cfd60860c Mon Sep 17 00:00:00 2001 From: eric-forte-elastic <119343520+eric-forte-elastic@users.noreply.github.com> Date: Thu, 6 Jul 2023 13:06:36 +0000 Subject: [PATCH] [FR] Add additional verification to BBR unit tests (#2909) * Fixes bug in unit tests * fix linting --- tests/test_all_rules.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_all_rules.py b/tests/test_all_rules.py index c16523a22..12f6d03ba 100644 --- a/tests/test_all_rules.py +++ b/tests/test_all_rules.py @@ -485,14 +485,23 @@ class TestRuleFiles(BaseRuleTest): def test_bbr_in_correct_dir(self): """Ensure that BBR are in the correct directory.""" for rule in self.bbr: + # Is the rule a BBR + self.assertEqual(rule.contents.data.building_block_type, 'default', + f'{self.rule_str(rule)} should have building_block_type = "default"') + + # Is the rule in the rules_building_block directory self.assertEqual(rule.path.parent.name, 'rules_building_block', f'{self.rule_str(rule)} should be in the rules_building_block directory') def test_non_bbr_in_correct_dir(self): """Ensure that non-BBR are not in BBR directory.""" + proper_directory = 'rules_building_block' for rule in self.all_rules: if rule.path.parent.name == 'rules_building_block': - self.assertIn(rule, self.bbr, f'{self.rule_str(rule)} should be in the rules_building_block directory') + self.assertIn(rule, self.bbr, f'{self.rule_str(rule)} should be in the {proper_directory}') + # Is the rule of type BBR + self.assertEqual(rule.contents.data.building_block_type, None, + f'{self.rule_str(rule)} should not have building_block_type or be in {proper_directory}') class TestRuleMetadata(BaseRuleTest):