88from hamcrest import (
99 assert_that ,
1010 contains_exactly ,
11+ contains_inanyorder ,
1112 equal_to ,
1213 has_entries ,
1314 has_entry ,
14- has_key , has_item , all_of , has_length , contains , has_items , contains_inanyorder ,
15+ has_key ,
1516)
1617
1718from eligibility_signposting_api .config .constants import CONSUMER_ID
@@ -825,78 +826,83 @@ def test_not_actionable_and_check_response_when_rule_mapper_is_given(
825826 ),
826827 )
827828
828-
829829 @pytest .mark .parametrize (
830- "campaign_configs, consumer_mapping_for_rsv_and_covid, consumer_id, requested_conditions, expected_targets" ,
830+ (
831+ "campaign_configs" ,
832+ "consumer_mapping_for_rsv_and_covid" ,
833+ "consumer_id" ,
834+ "requested_conditions" ,
835+ "expected_targets" ,
836+ ),
831837 [
832838 # Scenario 1: Intersection of mapped targets, requested targets, and active campaigns (Success)
833839 (
834- ["RSV" , "COVID" , "FLU" ],
835- "consumer_mapping_for_rsv_and_covid" ,
836- "consumer-id-mapped-to-rsv-and-covid" ,
837- "ALL" ,
838- ["RSV" , "COVID" ],
840+ ["RSV" , "COVID" , "FLU" ],
841+ "consumer_mapping_for_rsv_and_covid" ,
842+ "consumer-id-mapped-to-rsv-and-covid" ,
843+ "ALL" ,
844+ ["RSV" , "COVID" ],
839845 ),
840846 # Scenario 2: Explicit request for a single mapped target with an active campaign
841847 (
842- ["RSV" , "COVID" , "FLU" ],
843- "consumer_mapping_for_rsv_and_covid" ,
844- "consumer-id-mapped-to-rsv-and-covid" ,
845- "RSV" ,
846- ["RSV" ],
848+ ["RSV" , "COVID" , "FLU" ],
849+ "consumer_mapping_for_rsv_and_covid" ,
850+ "consumer-id-mapped-to-rsv-and-covid" ,
851+ "RSV" ,
852+ ["RSV" ],
847853 ),
848854 # Scenario 3: Request for an active campaign (FLU) that the consumer is NOT mapped to
849855 (
850- ["RSV" , "COVID" , "FLU" ],
851- "consumer_mapping_for_rsv_and_covid" ,
852- "consumer-id-mapped-to-rsv-and-covid" ,
853- "FLU" ,
854- [],
856+ ["RSV" , "COVID" , "FLU" ],
857+ "consumer_mapping_for_rsv_and_covid" ,
858+ "consumer-id-mapped-to-rsv-and-covid" ,
859+ "FLU" ,
860+ [],
855861 ),
856862 # Scenario 4: Request for a target that neither exists in system nor is mapped to consumer
857863 (
858- ["RSV" , "COVID" , "FLU" ],
859- "consumer_mapping_for_rsv_and_covid" ,
860- "consumer-id-mapped-to-rsv-and-covid" ,
861- "HPV" ,
862- [],
864+ ["RSV" , "COVID" , "FLU" ],
865+ "consumer_mapping_for_rsv_and_covid" ,
866+ "consumer-id-mapped-to-rsv-and-covid" ,
867+ "HPV" ,
868+ [],
863869 ),
864870 # Scenario 5: Consumer has no target mappings; requesting ALL should return empty
865871 (
866- ["RSV" , "COVID" , "FLU" ],
867- "consumer-id-mapped-to-rsv-and-covid" ,
868- "consumer-id-with-no-mapping" ,
869- "ALL" ,
870- [],
872+ ["RSV" , "COVID" , "FLU" ],
873+ "consumer-id-mapped-to-rsv-and-covid" ,
874+ "consumer-id-with-no-mapping" ,
875+ "ALL" ,
876+ [],
871877 ),
872878 # Scenario 6: Consumer has no target mappings; requesting specific target should return empty
873879 (
874- ["RSV" , "COVID" , "FLU" ],
875- "consumer-id-mapped-to-rsv-and-covid" ,
876- "consumer-id-with-no-mapping" ,
877- "RSV" ,
878- [],
880+ ["RSV" , "COVID" , "FLU" ],
881+ "consumer-id-mapped-to-rsv-and-covid" ,
882+ "consumer-id-with-no-mapping" ,
883+ "RSV" ,
884+ [],
879885 ),
880886 # Scenario 7: Consumer is mapped to targets (RSV/COVID), but those campaigns aren't active/present
881887 (
882- ["MMR" ],
883- "consumer_mapping_for_rsv_and_covid" ,
884- "consumer-id-mapped-to-rsv-and-covid" ,
885- "ALL" ,
886- [],
888+ ["MMR" ],
889+ "consumer_mapping_for_rsv_and_covid" ,
890+ "consumer-id-mapped-to-rsv-and-covid" ,
891+ "ALL" ,
892+ [],
887893 ),
888894 # Scenario 8: Request for specific mapped target (RSV), but those campaigns aren't active/present
889895 (
890- ["MMR" ],
891- "consumer_mapping_for_rsv_and_covid" ,
892- "consumer-id-mapped-to-rsv-and-covid" ,
893- "RSV" ,
894- [],
896+ ["MMR" ],
897+ "consumer_mapping_for_rsv_and_covid" ,
898+ "consumer-id-mapped-to-rsv-and-covid" ,
899+ "RSV" ,
900+ [],
895901 ),
896902 ],
897- indirect = ["campaign_configs" , "consumer_mapping_for_rsv_and_covid" ]
903+ indirect = ["campaign_configs" , "consumer_mapping_for_rsv_and_covid" ],
898904 )
899- def test_valid_response_when_consumer_has_a_valid_campaign_config_mapping (
905+ def test_valid_response_when_consumer_has_a_valid_campaign_config_mapping ( # noqa: PLR0913
900906 self ,
901907 client : FlaskClient ,
902908 persisted_person : NHSNumber ,
@@ -911,7 +917,9 @@ def test_valid_response_when_consumer_has_a_valid_campaign_config_mapping(
911917 headers = {"nhs-login-nhs-number" : str (persisted_person ), CONSUMER_ID : consumer_id }
912918
913919 # When
914- response = client .get (f"/patient-check/{ persisted_person } ?includeActions=Y&conditions={ requested_conditions } " , headers = headers )
920+ response = client .get (
921+ f"/patient-check/{ persisted_person } ?includeActions=Y&conditions={ requested_conditions } " , headers = headers
922+ )
915923
916924 assert_that (
917925 response ,
@@ -922,10 +930,8 @@ def test_valid_response_when_consumer_has_a_valid_campaign_config_mapping(
922930 has_entry (
923931 "processedSuggestions" ,
924932 # This ensures ONLY these items exist, no extras like FLU
925- contains_inanyorder (
926- * [has_entry ("condition" , i ) for i in expected_targets ]
927- )
933+ contains_inanyorder (* [has_entry ("condition" , i ) for i in expected_targets ]),
928934 )
929935 )
930- )
936+ ),
931937 )
0 commit comments