@@ -25,93 +25,6 @@ def rule_processor(mock_person_data_reader):
2525MOCK_PERSON_DATA = Person ([{"ATTRIBUTE_TYPE" : "PERSON" , "AGE" : "30" }])
2626
2727
28- def test_get_exclusion_rules_no_rules ():
29- cohort = rule_builder .IterationCohortFactory .build (cohort_label = "COHORT_A" )
30- rules_to_filter = []
31- result = list (RuleProcessor .get_exclusion_rules (cohort , rules_to_filter ))
32- assert_that (result , is_ ([]))
33-
34-
35- def test_get_exclusion_rules_general_rule ():
36- cohort = rule_builder .IterationCohortFactory .build (cohort_label = "COHORT_A" )
37- no_cohort_label_rule = rule_builder .IterationRuleFactory .build (cohort_label = None )
38- rules_to_filter = [no_cohort_label_rule ]
39- result = list (RuleProcessor .get_exclusion_rules (cohort , rules_to_filter ))
40- assert_that (result , is_ ([no_cohort_label_rule ]))
41-
42-
43- def test_get_exclusion_rules_matching_cohort_label ():
44- cohort = rule_builder .IterationCohortFactory .build (cohort_label = "COHORT_A" )
45- matching_rule = rule_builder .IterationRuleFactory .build (cohort_label = "COHORT_A" )
46- rules_to_filter = [matching_rule ]
47- result = list (RuleProcessor .get_exclusion_rules (cohort , rules_to_filter ))
48- assert_that (result , is_ ([matching_rule ]))
49-
50-
51- def test_get_exclusion_rules_matching_cohort_label_when_it_contains_multiple_cohort_labels ():
52- cohort = rule_builder .IterationCohortFactory .build (cohort_label = "COHORT_A" )
53- matching_rule = rule_builder .IterationRuleFactory .build (cohort_label = "COHORT_A,COHORT_B" )
54- rules_to_filter = [matching_rule ]
55- result = list (RuleProcessor .get_exclusion_rules (cohort , rules_to_filter ))
56- assert_that (result , is_ ([matching_rule ]))
57-
58-
59- def test_get_exclusion_rules_non_matching_cohort_label ():
60- cohort = rule_builder .IterationCohortFactory .build (cohort_label = "COHORT_A" )
61- non_matching_rule = rule_builder .IterationRuleFactory .build (cohort_label = "COHORT_B" )
62- rules_to_filter = [non_matching_rule ]
63- result = list (RuleProcessor .get_exclusion_rules (cohort , rules_to_filter ))
64- assert_that (result , is_ ([]))
65-
66-
67- def test_get_exclusion_rules_non_matching_cohort_label_when_it_contains_multiple_cohort_labels ():
68- cohort = rule_builder .IterationCohortFactory .build (cohort_label = "COHORT_A" )
69- non_matching_rule = rule_builder .IterationRuleFactory .build (cohort_label = "COHORT_B,COHORT_C" )
70- rules_to_filter = [non_matching_rule ]
71- result = list (RuleProcessor .get_exclusion_rules (cohort , rules_to_filter ))
72- assert_that (result , is_ ([]))
73-
74-
75- def test_get_exclusion_rules_matching_from_list_cohort_label ():
76- cohort = rule_builder .IterationCohortFactory .build (cohort_label = "COHORT_A" )
77- rule1 = rule_builder .IterationRuleFactory .build (cohort_label = "COHORT_A" )
78- rule2 = rule_builder .IterationRuleFactory .build (cohort_label = "COHORT_B" )
79- rules_to_filter = [rule1 , rule2 ]
80- result = list (RuleProcessor .get_exclusion_rules (cohort , rules_to_filter ))
81- assert_that (result , is_ ([rule1 ]))
82-
83-
84- def test_get_exclusion_rules_matching_from_list_cohort_label_when_it_contains_multiple_cohort_labels ():
85- cohort = rule_builder .IterationCohortFactory .build (cohort_label = "COHORT_A" )
86- rule1 = rule_builder .IterationRuleFactory .build (cohort_label = "COHORT_A" )
87- rule2 = rule_builder .IterationRuleFactory .build (cohort_label = "COHORT_B,COHORT_C" )
88- rules_to_filter = [rule1 , rule2 ]
89- result = list (RuleProcessor .get_exclusion_rules (cohort , rules_to_filter ))
90- assert_that (result , is_ ([rule1 ]))
91-
92-
93- def test_get_exclusion_rules_mixed_rules ():
94- cohort = rule_builder .IterationCohortFactory .build (cohort_label = "COHORT_A" )
95- no_cohort_label_rule = rule_builder .IterationRuleFactory .build (cohort_label = None , name = "General" )
96- matching_rule = rule_builder .IterationRuleFactory .build (cohort_label = "COHORT_A" , name = "Matching" )
97- non_matching_rule = rule_builder .IterationRuleFactory .build (cohort_label = "COHORT_B" , name = "NonMatching" )
98-
99- rules_to_filter = [no_cohort_label_rule , matching_rule , non_matching_rule ]
100- result = list (RuleProcessor .get_exclusion_rules (cohort , rules_to_filter ))
101- assert_that ({r .name for r in result }, is_ ({"General" , "Matching" }))
102-
103-
104- def test_get_exclusion_rules_mixed_rules_when_it_contains_multiple_cohort_labels ():
105- cohort = rule_builder .IterationCohortFactory .build (cohort_label = "COHORT_A" )
106- no_cohort_label_rule = rule_builder .IterationRuleFactory .build (cohort_label = None , name = "General" )
107- matching_rule = rule_builder .IterationRuleFactory .build (cohort_label = "COHORT_A,COHORT_C" , name = "Matching" )
108- non_matching_rule = rule_builder .IterationRuleFactory .build (cohort_label = "COHORT_B,COHORT_C" , name = "NonMatching" )
109-
110- rules_to_filter = [no_cohort_label_rule , matching_rule , non_matching_rule ]
111- result = list (RuleProcessor .get_exclusion_rules (cohort , rules_to_filter ))
112- assert_that ({r .name for r in result }, is_ ({"General" , "Matching" }))
113-
114-
11528@patch ("eligibility_signposting_api.services.processors.rule_processor.RuleCalculator" )
11629def test_evaluate_rules_priority_group_all_actionable (mock_rule_calculator_class , rule_processor ):
11730 mock_rule_calculator_class .return_value .evaluate_exclusion .return_value = (
0 commit comments