From 91e00adfdc1ac8be780798d026b776df14a13da5 Mon Sep 17 00:00:00 2001 From: karthikeyannhs <174426205+Karthikeyannhs@users.noreply.github.com> Date: Tue, 17 Feb 2026 15:28:22 +0000 Subject: [PATCH 1/3] ELI-580: added SUCCESSFUL_PROCEDURE_COUNT --- .../services/processors/token_processor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/eligibility_signposting_api/services/processors/token_processor.py b/src/eligibility_signposting_api/services/processors/token_processor.py index a97b69c8..16128dcc 100644 --- a/src/eligibility_signposting_api/services/processors/token_processor.py +++ b/src/eligibility_signposting_api/services/processors/token_processor.py @@ -20,6 +20,7 @@ "VALID_DOSES_COUNT", "INVALID_DOSES_COUNT", "LAST_SUCCESSFUL_DATE", + "SUCCESSFUL_PROCEDURE_COUNT", "LAST_VALID_DOSE_DATE", "BOOKED_APPOINTMENT_DATE", "BOOKED_APPOINTMENT_PROVIDER", From 41d987cfd23c59c1850b357e953a7b1ec2709a2d Mon Sep 17 00:00:00 2001 From: karthikeyannhs <174426205+Karthikeyannhs@users.noreply.github.com> Date: Tue, 17 Feb 2026 15:57:20 +0000 Subject: [PATCH 2/3] eli-580 unit test --- .../unit/services/processors/test_token_processor.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/unit/services/processors/test_token_processor.py b/tests/unit/services/processors/test_token_processor.py index 964aa5e6..01b6b123 100644 --- a/tests/unit/services/processors/test_token_processor.py +++ b/tests/unit/services/processors/test_token_processor.py @@ -608,18 +608,22 @@ def test_non_derived_token_with_invalid_target_attribute_raises_error(self): raises(ValueError, pattern="Invalid attribute name 'CUSTOM_INVALID_FIELD'"), ) - def test_non_derived_token_with_valid_target_attribute_works(self): + @pytest.mark.parametrize( + ("token", "expected"), + [("TARGET.COVID.LAST_SUCCESSFUL_DATE", 20260128), ("TARGET.COVID.SUCCESSFUL_PROCEDURE_COUNT", "3")], + ) + def test_non_derived_token_with_valid_target_attribute_works(self, token, expected): """Test that non-derived tokens with valid target attributes work correctly.""" person = Person( [ - {"ATTRIBUTE_TYPE": "COVID", "LAST_SUCCESSFUL_DATE": "20260128"}, + {"ATTRIBUTE_TYPE": "COVID", "LAST_SUCCESSFUL_DATE": "20260128", "SUCCESSFUL_PROCEDURE_COUNT": "3"}, ] ) condition = Condition( condition_name=ConditionName("Test"), status=Status.actionable, - status_text=StatusText("Last date: [[TARGET.COVID.LAST_SUCCESSFUL_DATE]]"), + status_text=StatusText(f"Last date: [[{token}]]"), cohort_results=[], suitability_rules=[], actions=[], @@ -627,7 +631,7 @@ def test_non_derived_token_with_valid_target_attribute_works(self): result = TokenProcessor.find_and_replace_tokens(person, condition) - assert_that(result.status_text, is_(equal_to("Last date: 20260128"))) + assert_that(result.status_text, is_(equal_to(f"Last date: {expected}"))) def test_person_level_attribute_with_add_days_without_explicit_source(self): """Test that ADD_DAYS works on PERSON-level attributes without explicit source.""" From af786671e5ecc4aa4f0eb3509be7614d4ef020c2 Mon Sep 17 00:00:00 2001 From: karthikeyannhs <174426205+Karthikeyannhs@users.noreply.github.com> Date: Tue, 17 Feb 2026 16:21:09 +0000 Subject: [PATCH 3/3] eli-580 lambda token tests --- tests/integration/conftest.py | 11 +++++++++-- .../integration/lambda/test_app_running_as_lambda.py | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 0cdf7f23..42d50c67 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -580,7 +580,7 @@ def person_with_all_data( gender="0", postcode="SW18", cohorts=["cohort_label1", "cohort_label2"], - vaccines={"RSV": {"LAST_SUCCESSFUL_DATE": None}}, + vaccines={"RSV": {"LAST_SUCCESSFUL_DATE": None, "SUCCESSFUL_PROCEDURE_COUNT": "3"}}, icb="QE1", gp_practice="C81002", pcn="U78207", @@ -952,12 +952,19 @@ def campaign_config_with_tokens(s3_client: BaseClient, rules_bucket: BucketName) ActionDescription="## Token - PERSON.GENDER: [[PERSON.GENDER]].", UrlLabel="Token - PERSON.DATE_OF_BIRTH: [[PERSON.DATE_OF_BIRTH]].", ), + "TOKEN_TEST3": AvailableAction( + ActionType="ButtonAuthLink", + ExternalRoutingCode="BookNBS", + ActionDescription="## " + "Token - TARGET.RSV.SUCCESSFUL_PROCEDURE_COUNT: [[TARGET.RSV.SUCCESSFUL_PROCEDURE_COUNT]].", + UrlLabel="", + ), } ), iteration_rules=[ rule.PostcodeSuppressionRuleFactory.build(), rule.PersonAgeSuppressionRuleFactory.build(), - rule.ICBNonEligibleActionRuleFactory.build(comms_routing="TOKEN_TEST|TOKEN_TEST2"), + rule.ICBNonEligibleActionRuleFactory.build(comms_routing="TOKEN_TEST|TOKEN_TEST2|TOKEN_TEST3"), rule.ICBNonActionableActionRuleFactory.build(comms_routing="TOKEN_TEST"), ], iteration_cohorts=[ diff --git a/tests/integration/lambda/test_app_running_as_lambda.py b/tests/integration/lambda/test_app_running_as_lambda.py index 08618038..51abcfe2 100644 --- a/tests/integration/lambda/test_app_running_as_lambda.py +++ b/tests/integration/lambda/test_app_running_as_lambda.py @@ -655,6 +655,7 @@ def test_token_formatting_in_eligibility_response_and_audit( # noqa: PLR0913 assert response_actions[0]["urlLabel"] == "Token - PERSON.DATE_OF_BIRTH:DATE(%d %B %Y): 28 February 1990." assert response_actions[1]["description"] == "## Token - PERSON.GENDER: 0." assert response_actions[1]["urlLabel"] == "Token - PERSON.DATE_OF_BIRTH: 19900228." + assert response_actions[2]["description"] == "## Token - TARGET.RSV.SUCCESSFUL_PROCEDURE_COUNT: 3." assert response_eligibility_cohorts[0]["cohortText"] == "Token - TARGET.RSV.LAST_SUCCESSFUL_DATE: " assert response_eligibility_cohorts[1]["cohortText"] == "Token - TARGET.RSV.LAST_SUCCESSFUL_DATE:DATE(%d %B %Y): " @@ -671,6 +672,7 @@ def test_token_formatting_in_eligibility_response_and_audit( # noqa: PLR0913 assert audit_actions[0]["actionUrlLabel"] == "Token - PERSON.DATE_OF_BIRTH:DATE(%d %B %Y): 28 February 1990." assert audit_actions[1]["actionDescription"] == "## Token - PERSON.GENDER: 0." assert audit_actions[1]["actionUrlLabel"] == "Token - PERSON.DATE_OF_BIRTH: 19900228." + assert audit_actions[2]["actionDescription"] == "## Token - TARGET.RSV.SUCCESSFUL_PROCEDURE_COUNT: 3." assert audit_eligibility_cohorts[0]["cohortText"] == "Token - TARGET.RSV.LAST_SUCCESSFUL_DATE: " assert audit_eligibility_cohorts[1]["cohortText"] == "Token - TARGET.RSV.LAST_SUCCESSFUL_DATE:DATE(%d %B %Y): "