Skip to content

Commit fecea11

Browse files
authored
Merge branch 'main' into feature/eja-eli-445-create-github-role-bootstrap-role
2 parents 3937be0 + 4ccf0ea commit fecea11

5 files changed

Lines changed: 24 additions & 7 deletions

File tree

infrastructure/stacks/api-layer/api_gateway.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ resource "aws_api_gateway_stage" "eligibility-signposting-api" {
5656
# A subscription filter (see csoc_log_forwarding.tf) forwards these logs to CSOC
5757
access_log_settings {
5858
destination_arn = module.eligibility_signposting_api_gateway.cloudwatch_destination_arn
59-
format = "{ \"requestId\":\"$context.requestId\", \"ip\": \"$context.identity.sourceIp\", \"caller\":\"$context.identity.caller\", \"user\":\"$context.identity.user\", \"requestTime\":\"$context.requestTime\", \"httpMethod\":\"$context.httpMethod\", \"resourcePath\":\"$context.resourcePath\", \"status\":\"$context.status\", \"protocol\":\"$context.protocol\", \"responseLength\":\"$context.responseLength\", \"accountId\":\"$context.accountId\", \"apiId\":\"$context.apiId\", \"stage\":\"$context.stage\", \"api_key\":\"$context.identity.apiKey\" }"
59+
format = "{ \"requestId\":\"$context.requestId\", \"ip\": \"$context.identity.sourceIp\", \"caller\":\"$context.identity.caller\", \"user\":\"$context.identity.user\", \"requestTime\":\"$context.requestTime\", \"httpMethod\":\"$context.httpMethod\", \"resourcePath\":\"$context.resourcePath\", \"status\":\"$context.status\", \"protocol\":\"$context.protocol\", \"responseLength\":\"$context.responseLength\", \"accountId\":\"$context.accountId\", \"apiId\":\"$context.apiId\", \"stage\":\"$context.stage\", \"api_key\":\"$context.identity.apiKey\", \"responseLatency\":\"$context.responseLatency\", \"integrationLatency\":\"$context.integrationLatency\" }"
6060

6161
}
6262

src/eligibility_signposting_api/services/processors/token_processor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"VALID_DOSES_COUNT",
2121
"INVALID_DOSES_COUNT",
2222
"LAST_SUCCESSFUL_DATE",
23+
"SUCCESSFUL_PROCEDURE_COUNT",
2324
"LAST_VALID_DOSE_DATE",
2425
"BOOKED_APPOINTMENT_DATE",
2526
"BOOKED_APPOINTMENT_PROVIDER",

tests/integration/conftest.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def person_with_all_data(
580580
gender="0",
581581
postcode="SW18",
582582
cohorts=["cohort_label1", "cohort_label2"],
583-
vaccines={"RSV": {"LAST_SUCCESSFUL_DATE": None}},
583+
vaccines={"RSV": {"LAST_SUCCESSFUL_DATE": None, "SUCCESSFUL_PROCEDURE_COUNT": "3"}},
584584
icb="QE1",
585585
gp_practice="C81002",
586586
pcn="U78207",
@@ -952,12 +952,19 @@ def campaign_config_with_tokens(s3_client: BaseClient, rules_bucket: BucketName)
952952
ActionDescription="## Token - PERSON.GENDER: [[PERSON.GENDER]].",
953953
UrlLabel="Token - PERSON.DATE_OF_BIRTH: [[PERSON.DATE_OF_BIRTH]].",
954954
),
955+
"TOKEN_TEST3": AvailableAction(
956+
ActionType="ButtonAuthLink",
957+
ExternalRoutingCode="BookNBS",
958+
ActionDescription="## "
959+
"Token - TARGET.RSV.SUCCESSFUL_PROCEDURE_COUNT: [[TARGET.RSV.SUCCESSFUL_PROCEDURE_COUNT]].",
960+
UrlLabel="",
961+
),
955962
}
956963
),
957964
iteration_rules=[
958965
rule.PostcodeSuppressionRuleFactory.build(),
959966
rule.PersonAgeSuppressionRuleFactory.build(),
960-
rule.ICBNonEligibleActionRuleFactory.build(comms_routing="TOKEN_TEST|TOKEN_TEST2"),
967+
rule.ICBNonEligibleActionRuleFactory.build(comms_routing="TOKEN_TEST|TOKEN_TEST2|TOKEN_TEST3"),
961968
rule.ICBNonActionableActionRuleFactory.build(comms_routing="TOKEN_TEST"),
962969
],
963970
iteration_cohorts=[

tests/integration/lambda/test_app_running_as_lambda.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ def test_token_formatting_in_eligibility_response_and_audit( # noqa: PLR0913
655655
assert response_actions[0]["urlLabel"] == "Token - PERSON.DATE_OF_BIRTH:DATE(%d %B %Y): 28 February 1990."
656656
assert response_actions[1]["description"] == "## Token - PERSON.GENDER: 0."
657657
assert response_actions[1]["urlLabel"] == "Token - PERSON.DATE_OF_BIRTH: 19900228."
658+
assert response_actions[2]["description"] == "## Token - TARGET.RSV.SUCCESSFUL_PROCEDURE_COUNT: 3."
658659
assert response_eligibility_cohorts[0]["cohortText"] == "Token - TARGET.RSV.LAST_SUCCESSFUL_DATE: "
659660
assert response_eligibility_cohorts[1]["cohortText"] == "Token - TARGET.RSV.LAST_SUCCESSFUL_DATE:DATE(%d %B %Y): "
660661

@@ -671,6 +672,7 @@ def test_token_formatting_in_eligibility_response_and_audit( # noqa: PLR0913
671672
assert audit_actions[0]["actionUrlLabel"] == "Token - PERSON.DATE_OF_BIRTH:DATE(%d %B %Y): 28 February 1990."
672673
assert audit_actions[1]["actionDescription"] == "## Token - PERSON.GENDER: 0."
673674
assert audit_actions[1]["actionUrlLabel"] == "Token - PERSON.DATE_OF_BIRTH: 19900228."
675+
assert audit_actions[2]["actionDescription"] == "## Token - TARGET.RSV.SUCCESSFUL_PROCEDURE_COUNT: 3."
674676
assert audit_eligibility_cohorts[0]["cohortText"] == "Token - TARGET.RSV.LAST_SUCCESSFUL_DATE: "
675677
assert audit_eligibility_cohorts[1]["cohortText"] == "Token - TARGET.RSV.LAST_SUCCESSFUL_DATE:DATE(%d %B %Y): "
676678

tests/unit/services/processors/test_token_processor.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,26 +608,33 @@ def test_non_derived_token_with_invalid_target_attribute_raises_error(self):
608608
raises(ValueError, pattern="Invalid attribute name 'CUSTOM_INVALID_FIELD'"),
609609
)
610610

611-
def test_non_derived_token_with_valid_target_attribute_works(self):
611+
@pytest.mark.parametrize(
612+
("token", "expected"),
613+
[
614+
("TARGET.COVID.LAST_SUCCESSFUL_DATE", 20260128), # expect value which is an integer
615+
("TARGET.COVID.SUCCESSFUL_PROCEDURE_COUNT", "3"), # expect value which is a string
616+
],
617+
)
618+
def test_non_derived_token_with_valid_target_attribute_works(self, token, expected):
612619
"""Test that non-derived tokens with valid target attributes work correctly."""
613620
person = Person(
614621
[
615-
{"ATTRIBUTE_TYPE": "COVID", "LAST_SUCCESSFUL_DATE": "20260128"},
622+
{"ATTRIBUTE_TYPE": "COVID", "LAST_SUCCESSFUL_DATE": "20260128", "SUCCESSFUL_PROCEDURE_COUNT": "3"},
616623
]
617624
)
618625

619626
condition = Condition(
620627
condition_name=ConditionName("Test"),
621628
status=Status.actionable,
622-
status_text=StatusText("Last date: [[TARGET.COVID.LAST_SUCCESSFUL_DATE]]"),
629+
status_text=StatusText(f"test token: [[{token}]]"),
623630
cohort_results=[],
624631
suitability_rules=[],
625632
actions=[],
626633
)
627634

628635
result = TokenProcessor.find_and_replace_tokens(person, condition)
629636

630-
assert_that(result.status_text, is_(equal_to("Last date: 20260128")))
637+
assert_that(result.status_text, is_(equal_to(f"test token: {expected}")))
631638

632639
def test_person_level_attribute_with_add_days_without_explicit_source(self):
633640
"""Test that ADD_DAYS works on PERSON-level attributes without explicit source."""

0 commit comments

Comments
 (0)