2323)
2424from yarl import URL
2525
26+ from eligibility_signposting_api .config .constants import CONSUMER_ID
2627from eligibility_signposting_api .model .campaign_config import CampaignConfig
28+ from eligibility_signposting_api .model .consumer_mapping import ConsumerMapping
2729from eligibility_signposting_api .model .eligibility_status import NHSNumber
2830from eligibility_signposting_api .repos .campaign_repo import BucketName
2931
@@ -35,6 +37,7 @@ def test_install_and_call_lambda_flask(
3537 flask_function : str ,
3638 persisted_person : NHSNumber ,
3739 campaign_config : CampaignConfig , # noqa: ARG001
40+ consumer_mapping : ConsumerMapping , # noqa: ARG001
3841):
3942 """Given lambda installed into localstack, run it via boto3 lambda client"""
4043 # Given
@@ -49,6 +52,7 @@ def test_install_and_call_lambda_flask(
4952 "accept" : "application/json" ,
5053 "content-type" : "application/json" ,
5154 "nhs-login-nhs-number" : str (persisted_person ),
55+ CONSUMER_ID : "23-mic7heal-jor6don" ,
5256 },
5357 "pathParameters" : {"id" : str (persisted_person )},
5458 "requestContext" : {
@@ -86,6 +90,7 @@ def test_install_and_call_lambda_flask(
8690def test_install_and_call_flask_lambda_over_http (
8791 persisted_person : NHSNumber ,
8892 campaign_config : CampaignConfig , # noqa: ARG001
93+ consumer_mapping : ConsumerMapping , # noqa: ARG001
8994 api_gateway_endpoint : URL ,
9095):
9196 """Given api-gateway and lambda installed into localstack, run it via http"""
@@ -94,7 +99,7 @@ def test_install_and_call_flask_lambda_over_http(
9499 invoke_url = f"{ api_gateway_endpoint } /patient-check/{ persisted_person } "
95100 response = httpx .get (
96101 invoke_url ,
97- headers = {"nhs-login-nhs-number" : str (persisted_person )},
102+ headers = {"nhs-login-nhs-number" : str (persisted_person ), CONSUMER_ID : "23-mic7heal-jor6don" },
98103 timeout = 10 ,
99104 )
100105
@@ -105,10 +110,11 @@ def test_install_and_call_flask_lambda_over_http(
105110 )
106111
107112
108- def test_install_and_call_flask_lambda_with_unknown_nhs_number (
113+ def test_install_and_call_flask_lambda_with_unknown_nhs_number ( # noqa: PLR0913
109114 flask_function : str ,
110115 persisted_person : NHSNumber ,
111116 campaign_config : CampaignConfig , # noqa: ARG001
117+ consumer_mapping : ConsumerMapping , # noqa: ARG001
112118 logs_client : BaseClient ,
113119 api_gateway_endpoint : URL ,
114120):
@@ -120,7 +126,7 @@ def test_install_and_call_flask_lambda_with_unknown_nhs_number(
120126 invoke_url = f"{ api_gateway_endpoint } /patient-check/{ nhs_number } "
121127 response = httpx .get (
122128 invoke_url ,
123- headers = {"nhs-login-nhs-number" : str (nhs_number )},
129+ headers = {"nhs-login-nhs-number" : str (nhs_number ), CONSUMER_ID : "23-mic7heal-jor6don" },
124130 timeout = 10 ,
125131 )
126132
@@ -182,6 +188,7 @@ def test_given_nhs_number_in_path_matches_with_nhs_number_in_headers_and_check_i
182188 lambda_client : BaseClient , # noqa:ARG001
183189 persisted_person : NHSNumber ,
184190 campaign_config : CampaignConfig ,
191+ consumer_mapping : ConsumerMapping , # noqa: ARG001
185192 s3_client : BaseClient ,
186193 audit_bucket : BucketName ,
187194 api_gateway_endpoint : URL ,
@@ -195,6 +202,7 @@ def test_given_nhs_number_in_path_matches_with_nhs_number_in_headers_and_check_i
195202 invoke_url ,
196203 headers = {
197204 "nhs-login-nhs-number" : str (persisted_person ),
205+ CONSUMER_ID : "23-mic7heal-jor6don" ,
198206 "x_request_id" : "x_request_id" ,
199207 "x_correlation_id" : "x_correlation_id" ,
200208 "nhsd_end_user_organisation_ods" : "nhsd_end_user_organisation_ods" ,
@@ -371,14 +379,15 @@ def test_validation_of_query_params_when_all_are_valid(
371379 lambda_client : BaseClient , # noqa:ARG001
372380 persisted_person : NHSNumber ,
373381 campaign_config : CampaignConfig , # noqa:ARG001
382+ consumer_mapping : ConsumerMapping , # noqa: ARG001
374383 api_gateway_endpoint : URL ,
375384):
376385 # Given
377386 # When
378387 invoke_url = f"{ api_gateway_endpoint } /patient-check/{ persisted_person } "
379388 response = httpx .get (
380389 invoke_url ,
381- headers = {"nhs-login-nhs-number" : persisted_person },
390+ headers = {"nhs-login-nhs-number" : persisted_person , CONSUMER_ID : "23-mic7heal-jor6don" },
382391 params = {"category" : "VACCINATIONS" , "conditions" : "COVID19" , "includeActions" : "N" },
383392 timeout = 10 ,
384393 )
@@ -411,6 +420,7 @@ def test_given_person_has_unique_status_for_different_conditions_with_audit( #
411420 lambda_client : BaseClient , # noqa:ARG001
412421 persisted_person_all_cohorts : NHSNumber ,
413422 multiple_campaign_configs : list [CampaignConfig ],
423+ consumer_mapping : ConsumerMapping , # noqa: ARG001
414424 s3_client : BaseClient ,
415425 audit_bucket : BucketName ,
416426 api_gateway_endpoint : URL ,
@@ -420,6 +430,7 @@ def test_given_person_has_unique_status_for_different_conditions_with_audit( #
420430 invoke_url ,
421431 headers = {
422432 "nhs-login-nhs-number" : str (persisted_person_all_cohorts ),
433+ CONSUMER_ID : "23-mic7heal-jor6don" ,
423434 "x_request_id" : "x_request_id" ,
424435 "x_correlation_id" : "x_correlation_id" ,
425436 "nhsd_end_user_organisation_ods" : "nhsd_end_user_organisation_ods" ,
@@ -554,13 +565,15 @@ def test_no_active_iteration_returns_empty_processed_suggestions(
554565 lambda_client : BaseClient , # noqa:ARG001
555566 persisted_person_all_cohorts : NHSNumber ,
556567 inactive_iteration_config : list [CampaignConfig ], # noqa:ARG001
568+ consumer_mapping_with_various_targets : ConsumerMapping , # noqa:ARG001
557569 api_gateway_endpoint : URL ,
558570):
559571 invoke_url = f"{ api_gateway_endpoint } /patient-check/{ persisted_person_all_cohorts } "
560572 response = httpx .get (
561573 invoke_url ,
562574 headers = {
563575 "nhs-login-nhs-number" : str (persisted_person_all_cohorts ),
576+ CONSUMER_ID : "23-mic7heal-jor6don" ,
564577 "x_request_id" : "x_request_id" ,
565578 "x_correlation_id" : "x_correlation_id" ,
566579 "nhsd_end_user_organisation_ods" : "nhsd_end_user_organisation_ods" ,
@@ -590,6 +603,7 @@ def test_token_formatting_in_eligibility_response_and_audit( # noqa: PLR0913
590603 lambda_client : BaseClient , # noqa:ARG001
591604 person_with_all_data : NHSNumber ,
592605 campaign_config_with_tokens : CampaignConfig , # noqa:ARG001
606+ consumer_mapping : ConsumerMapping , # noqa:ARG001
593607 s3_client : BaseClient ,
594608 audit_bucket : BucketName ,
595609 api_gateway_endpoint : URL ,
@@ -599,7 +613,7 @@ def test_token_formatting_in_eligibility_response_and_audit( # noqa: PLR0913
599613 invoke_url = f"{ api_gateway_endpoint } /patient-check/{ person_with_all_data } "
600614 response = httpx .get (
601615 invoke_url ,
602- headers = {"nhs-login-nhs-number" : str (person_with_all_data )},
616+ headers = {"nhs-login-nhs-number" : str (person_with_all_data ), CONSUMER_ID : "23-mic7heal-jor6don" },
603617 timeout = 10 ,
604618 )
605619
@@ -640,6 +654,7 @@ def test_incorrect_token_causes_internal_server_error( # noqa: PLR0913
640654 lambda_client : BaseClient , # noqa:ARG001
641655 person_with_all_data : NHSNumber ,
642656 campaign_config_with_invalid_tokens : CampaignConfig , # noqa:ARG001
657+ consumer_mapping : ConsumerMapping , # noqa: ARG001
643658 s3_client : BaseClient ,
644659 audit_bucket : BucketName ,
645660 api_gateway_endpoint : URL ,
@@ -649,7 +664,7 @@ def test_incorrect_token_causes_internal_server_error( # noqa: PLR0913
649664 invoke_url = f"{ api_gateway_endpoint } /patient-check/{ person_with_all_data } "
650665 response = httpx .get (
651666 invoke_url ,
652- headers = {"nhs-login-nhs-number" : str (person_with_all_data )},
667+ headers = {"nhs-login-nhs-number" : str (person_with_all_data ), CONSUMER_ID : "23-mic7heal-jor6don" },
653668 timeout = 10 ,
654669 )
655670
0 commit comments