|
8 | 8 | from eligibility_signposting_api.model import rules |
9 | 9 | from eligibility_signposting_api.model import rules as rules_model |
10 | 10 | from eligibility_signposting_api.model.eligibility import ConditionName, DateOfBirth, NHSNumber, Postcode, Status |
11 | | -from eligibility_signposting_api.model.rules import IterationRule |
12 | 11 | from eligibility_signposting_api.services.calculators.eligibility_calculator import EligibilityCalculator |
13 | 12 | from tests.fixtures.builders.model import rule as rule_builder |
14 | 13 | from tests.fixtures.builders.repos.person import person_rows_builder |
@@ -817,49 +816,30 @@ def test_status_if_iteration_rules_contains_cohort_label_field( |
817 | 816 | @pytest.mark.parametrize( |
818 | 817 | ("rule_stop", "expected_status", "test_comment"), |
819 | 818 | [ |
820 | | - ("Y", Status.not_actionable, "Stops at the first rule"), |
821 | | - ("N", Status.not_eligible, "Both the rules are executed"), |
822 | | - ("", Status.not_eligible, "Both the rules are executed"), |
823 | | - (None, Status.not_eligible, "Both the rules are executed"), |
| 819 | + (True, Status.not_actionable, "Stops at the first rule"), |
| 820 | + (False, Status.not_eligible, "Both the rules are executed"), |
824 | 821 | ], |
825 | 822 | ) |
826 | | -def test_rules_stop_behavior(rule_stop: str | None, expected_status: Status, test_comment: str, faker: Faker) -> None: |
| 823 | +def test_rules_stop_behavior(rule_stop: bool, expected_status: Status, test_comment: str, faker: Faker) -> None: # noqa: FBT001 |
827 | 824 | # Given |
828 | 825 | nhs_number = NHSNumber(faker.nhs_number()) |
829 | 826 | date_of_birth = DateOfBirth(faker.date_of_birth(minimum_age=18, maximum_age=74)) |
830 | 827 | person_rows = person_rows_builder(nhs_number, date_of_birth=date_of_birth, cohorts=["cohort1"]) |
831 | 828 |
|
832 | | - # Base rule template |
833 | | - # Not using model factory to create Iteration rules since it sets boolean values for "Y"/"N" |
834 | | - simple_age_data = { |
835 | | - "Name": "Exclude too young less than 75", |
836 | | - "Description": "Exclude too young less than 75", |
837 | | - "AttributeLevel": "PERSON", |
838 | | - "AttributeName": "DATE_OF_BIRTH", |
839 | | - "Operator": "Y>", |
840 | | - "Comparator": "-75", |
841 | | - } |
842 | | - |
843 | | - # Build rule variations |
844 | | - rule_variants = [ |
845 | | - {"Type": "S", "Priority": 10, "RuleStop": rule_stop}, |
846 | | - {"Type": "S", "Priority": 10}, |
847 | | - {"Type": "F", "Priority": 15}, |
848 | | - ] |
849 | | - |
850 | | - iteration_rules = [IterationRule.model_validate({**simple_age_data, **variant}) for variant in rule_variants] |
851 | | - |
852 | 829 | # Build campaign configuration |
853 | 830 | campaign_config = rule_builder.CampaignConfigFactory.build( |
854 | 831 | target="RSV", |
855 | 832 | iterations=[ |
856 | 833 | rule_builder.IterationFactory.build( |
857 | | - iteration_rules=[], |
| 834 | + iteration_rules=[ |
| 835 | + rule_builder.PersonAgeSuppressionRuleFactory.build(priority=10, rule_stop=rule_stop), |
| 836 | + rule_builder.PersonAgeSuppressionRuleFactory.build(priority=10), |
| 837 | + rule_builder.PersonAgeSuppressionRuleFactory.build(type=rules.RuleType.filter, priority=15), |
| 838 | + ], |
858 | 839 | iteration_cohorts=[rule_builder.IterationCohortFactory.build(cohort_label="cohort1")], |
859 | 840 | ) |
860 | 841 | ], |
861 | 842 | ) |
862 | | - campaign_config.iterations[0].iteration_rules.extend(iteration_rules) |
863 | 843 |
|
864 | 844 | calculator = EligibilityCalculator(person_rows, [campaign_config]) |
865 | 845 |
|
|
0 commit comments