Skip to content

Commit 83ab6bc

Browse files
description based on priority in a cohort group
1 parent 873516a commit 83ab6bc

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

tests/unit/services/calculators/test_eligibility_calculator.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,3 +1226,73 @@ def test_grouped_description_for_multiple_clinical_risk_cohort_if_best_status_is
12261226
),
12271227
test_comment,
12281228
)
1229+
1230+
1231+
@pytest.mark.parametrize(
1232+
("person_rows", "expected_description", "test_comment"),
1233+
[
1234+
(
1235+
person_rows_builder(nhs_number="123", cohorts=[]),
1236+
"rsv_age_range negative description 1",
1237+
"status - not eligible",
1238+
),
1239+
(
1240+
person_rows_builder(nhs_number="123", cohorts=["rsv_75_rolling", "rsv_75to79_2024"], postcode="SW19"),
1241+
"rsv_age_range positive description 1",
1242+
"status - not actionable",
1243+
),
1244+
(
1245+
person_rows_builder(nhs_number="123", cohorts=["rsv_75_rolling", "rsv_75to79_2024"], postcode="hp"),
1246+
"rsv_age_range positive description 1",
1247+
"status - actionable",
1248+
),
1249+
],
1250+
)
1251+
def test_grouped_description_if_the_cohorts_in_group_have_different_descriptions(
1252+
person_rows: list[dict[str, Any]], expected_description: str, test_comment: str
1253+
):
1254+
# Given
1255+
campaign_configs = [
1256+
rule_builder.CampaignConfigFactory.build(
1257+
target="RSV",
1258+
iterations=[
1259+
rule_builder.IterationFactory.build(
1260+
iteration_cohorts=[
1261+
rule_builder.Rsv75RollingCohortFactory.build(
1262+
positive_description=rules.Description("rsv_age_range positive description 1"),
1263+
negative_description=rules.Description("rsv_age_range negative description 1"),
1264+
priority=1,
1265+
),
1266+
rule_builder.Rsv75to79CohortFactory.build(
1267+
positive_description=rules.Description("rsv_age_range positive description 2"),
1268+
negative_description=rules.Description("rsv_age_range negative description 2"),
1269+
priority=2,
1270+
),
1271+
],
1272+
iteration_rules=[rule_builder.PostcodeSuppressionRuleFactory.build()],
1273+
)
1274+
],
1275+
)
1276+
]
1277+
1278+
calculator = EligibilityCalculator(person_rows, campaign_configs)
1279+
1280+
# When
1281+
actual = calculator.evaluate_eligibility()
1282+
1283+
# Then
1284+
assert_that(
1285+
actual,
1286+
is_eligibility_status().with_conditions(
1287+
has_items(
1288+
is_condition()
1289+
.with_condition_name(ConditionName("RSV"))
1290+
.and_cohort_results(
1291+
contains_exactly(
1292+
is_cohort_result().with_cohort_code("rsv_age_range").with_description(expected_description)
1293+
)
1294+
)
1295+
)
1296+
),
1297+
test_comment,
1298+
)

0 commit comments

Comments
 (0)