Skip to content

Commit a5f5f1e

Browse files
committed
all tests passing
1 parent 03fcfd9 commit a5f5f1e

4 files changed

Lines changed: 15 additions & 20 deletions

File tree

src/eligibility_signposting_api/services/processors/rule_processor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ def is_actionable(
9494
if not applicable_rules:
9595
continue
9696

97-
status, group_exclusion_reasons, rule_stop = self.evaluate_rules_priority_group(person, rule_group)
97+
status, group_exclusion_reasons, rule_stop = self.evaluate_rules_priority_group(
98+
person, iter(applicable_rules)
99+
)
98100
if status.is_exclusion:
99101
is_actionable = False
100102
suppression_reasons.extend(group_exclusion_reasons)

tests/integration/conftest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,14 +480,17 @@ def campaign_config(s3_client: BaseClient, rules_bucket: BucketName) -> Generato
480480
yield campaign
481481
s3_client.delete_object(Bucket=rules_bucket, Key=f"{campaign.name}.json")
482482

483+
483484
@pytest.fixture(scope="class")
484485
def campaign_config_with_and_rule(s3_client: BaseClient, rules_bucket: BucketName) -> Generator[CampaignConfig]:
485486
campaign: CampaignConfig = rule.CampaignConfigFactory.build(
486487
target="RSV",
487488
iterations=[
488489
rule.IterationFactory.build(
489490
iteration_rules=[
490-
rule.PostcodeSuppressionRuleFactory.build(cohort_label="cohort2",),
491+
rule.PostcodeSuppressionRuleFactory.build(
492+
cohort_label="cohort2",
493+
),
491494
rule.PersonAgeSuppressionRuleFactory.build(),
492495
],
493496
iteration_cohorts=[
@@ -502,7 +505,7 @@ def campaign_config_with_and_rule(s3_client: BaseClient, rules_bucket: BucketNam
502505
cohort_group="cohort_group2",
503506
positive_description="positive_description",
504507
negative_description="negative_description",
505-
)
508+
),
506509
],
507510
)
508511
],

tests/integration/in_process/test_eligibility_endpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ def test_actionable(
237237
),
238238
)
239239

240-
241240
def test_actionable_with_and_rule(
242241
self,
243242
client: FlaskClient,
@@ -289,6 +288,7 @@ def test_actionable_with_and_rule(
289288
),
290289
)
291290

291+
292292
class TestMagicCohortResponse:
293293
def test_not_eligible_by_rule_when_only_magic_cohort_is_present(
294294
self,

tests/unit/services/processors/test_rule_processor.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,17 @@ def test_general_rule_should_not_evaluate_in_isolation_without_matching_specific
150150
rule_processor,
151151
):
152152
# Person is in COHORT_B
153-
cohort = rule_builder.IterationCohortFactory.build(
154-
cohort_label="COHORT_B",
155-
positive_description="Eligible"
156-
)
153+
cohort = rule_builder.IterationCohortFactory.build(cohort_label="COHORT_B", positive_description="Eligible")
157154
cohort_results = {}
158155

159156
# Rule 1: cohort-specific to COHORT_A — should be filtered out
160157
rule_specific = rule_builder.IterationRuleFactory.build(
161-
priority=510,
162-
type=RuleType.suppression,
163-
cohort_label="COHORT_A",
164-
name="SPECIFIC_RULE"
158+
priority=510, type=RuleType.suppression, cohort_label="COHORT_A", name="SPECIFIC_RULE"
165159
)
166160

167161
# Rule 2: General rule
168162
rule_general = rule_builder.IterationRuleFactory.build(
169-
priority=510,
170-
type=RuleType.suppression,
171-
cohort_label=None,
172-
name="GENERAL_RULE"
163+
priority=510, type=RuleType.suppression, cohort_label=None, name="GENERAL_RULE"
173164
)
174165

175166
suppression_rules = [rule_specific, rule_general]
@@ -184,7 +175,6 @@ def test_general_rule_should_not_evaluate_in_isolation_without_matching_specific
184175
assert_that(cohort_results["COHORT_B"].status, is_(Status.actionable))
185176

186177

187-
188178
@patch.object(RuleProcessor, "evaluate_rules_priority_group")
189179
@patch.object(RuleProcessor, "get_exclusion_rules", side_effect=lambda cohort, rules_to_filter: rules_to_filter) # noqa: ARG005
190180
def test_is_eligible_by_filter_rules_eligible(
@@ -305,8 +295,8 @@ def test_evaluate_suppression_rules_stops_on_rule_stop(
305295
assert_that(cohort_results["COHORT_A"].status, is_(Status.not_actionable))
306296
assert_that(cohort_results["COHORT_A"].reasons, is_([mock_reason_p1]))
307297
assert_that(cohort_results["COHORT_A"].audit_rules, is_([mock_reason_p1]))
308-
mock_evaluate_rules_priority_group.assert_called_once()
309-
mock_get_exclusion_rules.assert_called_once_with(cohort, suppression_rules)
298+
assert_that(mock_evaluate_rules_priority_group.call_count, is_(1))
299+
mock_get_exclusion_rules.assert_called_once_with(cohort, [suppression_rule_p1])
310300

311301

312302
@patch.object(RuleProcessor, "evaluate_rules_priority_group")
@@ -338,7 +328,7 @@ def test_evaluate_suppression_rules_does_not_stop_on_rule_stop_when_status_is_ac
338328
assert_that(cohort_results["COHORT_A"].audit_rules, is_([mock_reason_p2]))
339329

340330
assert_that(mock_evaluate_rules_priority_group.call_count, is_(2))
341-
assert_that(mock_get_exclusion_rules.call_count, is_(1))
331+
assert_that(mock_get_exclusion_rules.call_count, is_(2))
342332

343333

344334
def test_is_base_eligible(mock_person_data_reader):

0 commit comments

Comments
 (0)