@@ -205,7 +205,7 @@ def test_only_live_campaigns_considered(faker: Faker):
205205 "iteration_type" ,
206206 ["A" , "M" , "S" , "O" ],
207207)
208- def test_campaigns_with_applicable_iteration_types_considered (iteration_type : str , faker : Faker ):
208+ def test_campaigns_with_applicable_iteration_types_in_campaign_level_considered (iteration_type : str , faker : Faker ):
209209 # Given
210210 nhs_number = NHSNumber (faker .nhs_number ())
211211
@@ -230,15 +230,59 @@ def test_campaigns_with_applicable_iteration_types_considered(iteration_type: st
230230 )
231231
232232
233+ @pytest .mark .parametrize (
234+ "iteration_type" ,
235+ ["A" , "M" , "S" , "O" ],
236+ )
237+ def test_campaigns_with_applicable_iteration_types_in_iteration_level_considered (iteration_type : str , faker : Faker ):
238+ # Given
239+ nhs_number = NHSNumber (faker .nhs_number ())
240+
241+ person_rows = person_rows_builder (nhs_number )
242+ campaign_configs = [
243+ rule_builder .CampaignConfigFactory .build (
244+ target = "RSV" , iterations = [rule_builder .IterationFactory .build (type = iteration_type )]
245+ )
246+ ]
247+
248+ calculator = EligibilityCalculator (person_rows , campaign_configs )
249+
250+ # When
251+ actual = calculator .evaluate_eligibility ()
252+
253+ # Then
254+ assert_that (
255+ actual ,
256+ is_eligibility_status ().with_conditions (
257+ has_item (
258+ is_condition ()
259+ .with_condition_name (ConditionName ("RSV" ))
260+ .and_status (is_in ([Status .actionable , Status .not_actionable , Status .not_eligible ]))
261+ ),
262+ ),
263+ )
264+
265+
233266@pytest .mark .parametrize (
234267 "iteration_type" ,
235268 ["NA" , "N" , "FAKE" , "F" ],
236269)
237- def test_invalid_iteration_type_raises_validation_error (iteration_type : str ):
270+ def test_invalid_iteration_types_in_campaign_level_raises_validation_error (iteration_type : str ):
238271 with pytest .raises (ValidationError ):
239272 rule_builder .CampaignConfigFactory .build (target = "RSV" , iteration_type = iteration_type )
240273
241274
275+ @pytest .mark .parametrize (
276+ "iteration_type" ,
277+ ["NA" , "N" , "FAKE" , "F" ],
278+ )
279+ def test_invalid_iteration_types_in_iteration_level_raises_validation_error (iteration_type : str ):
280+ with pytest .raises (ValidationError ):
281+ rule_builder .CampaignConfigFactory .build (
282+ target = "RSV" , iterations = [rule_builder .IterationFactory .build (type = iteration_type )]
283+ )
284+
285+
242286def test_base_eligible_and_simple_rule_includes (faker : Faker ):
243287 # Given
244288 nhs_number = NHSNumber (faker .nhs_number ())
@@ -1730,47 +1774,47 @@ def test_cohort_group_descriptions_pick_first_non_empty_if_available(
17301774 [
17311775 (
17321776 """Rule match: default_comms_routing present, action_mapper present,
1733- return actions from matching comms from rule""" ,
1777+ return actions from matching comms from rule""" ,
17341778 "defaultcomms" ,
17351779 "InternalBookNBS" ,
17361780 {"InternalBookNBS" : book_nbs_comms , "defaultcomms" : default_comms_detail },
17371781 SuggestedActions ([suggested_action_for_book_nbs ]),
17381782 ),
17391783 (
17401784 """Rule match: default_comms_routing has multiple values,
1741- comms missing in rule, all default comms should be returned in actions""" ,
1785+ comms missing in rule, all default comms should be returned in actions""" ,
17421786 "defaultcomms1|defaultcomms2" ,
17431787 None ,
17441788 {"defaultcomms1" : default_comms_detail , "defaultcomms2" : default_comms_detail },
17451789 SuggestedActions ([suggested_action_for_default_comms , suggested_action_for_default_comms ]),
17461790 ),
17471791 (
17481792 """Rule match: default_comms_routing has multiple values,
1749- comms is empty string, all default comms should be returned in actions""" ,
1793+ comms is empty string, all default comms should be returned in actions""" ,
17501794 "defaultcomms1" ,
17511795 "" ,
17521796 {"defaultcomms1" : default_comms_detail },
17531797 SuggestedActions ([suggested_action_for_default_comms ]),
17541798 ),
17551799 (
17561800 """Rule match: default_comms_routing present,
1757- action_mapper missing for matching comms, return default_comms in actions""" ,
1801+ action_mapper missing for matching comms, return default_comms in actions""" ,
17581802 "defaultcomms" ,
17591803 "InternalBookNBS" ,
17601804 {"defaultcomms" : default_comms_detail },
17611805 SuggestedActions ([suggested_action_for_default_comms ]),
17621806 ),
17631807 (
17641808 """Rule match: default_comms_routing present,
1765- rule has an incorrect comms key, return default_comms in actions""" ,
1809+ rule has an incorrect comms key, return default_comms in actions""" ,
17661810 "defaultcomms" ,
17671811 "InvalidCode" ,
17681812 {"defaultcomms" : default_comms_detail },
17691813 SuggestedActions ([suggested_action_for_default_comms ]),
17701814 ),
17711815 (
17721816 """Rule match: action_mapper present without url,
1773- return actions from matching comms from rule""" ,
1817+ return actions from matching comms from rule""" ,
17741818 "defaultcomms" ,
17751819 "InternalBookNBS" ,
17761820 {
@@ -1794,31 +1838,31 @@ def test_cohort_group_descriptions_pick_first_non_empty_if_available(
17941838 ),
17951839 (
17961840 """Rule match: default_comms_routing missing,
1797- comms present in rule, action_mapper missing, return no actions""" ,
1841+ comms present in rule, action_mapper missing, return no actions""" ,
17981842 "" ,
17991843 "InternalBookNBS" ,
18001844 {},
18011845 SuggestedActions ([]),
18021846 ),
18031847 (
18041848 """Rule match: default_comms_routing missing, but action_mapper present,
1805- return actions from matching comms from rule""" ,
1849+ return actions from matching comms from rule""" ,
18061850 "" ,
18071851 "InternalBookNBS" ,
18081852 {"InternalBookNBS" : book_nbs_comms },
18091853 SuggestedActions ([suggested_action_for_book_nbs ]),
18101854 ),
18111855 (
18121856 """Rule match: default_comms_routing present,
1813- comms present in rule, but action_mapper missing, return no actions""" ,
1857+ comms present in rule, but action_mapper missing, return no actions""" ,
18141858 "defaultcommskeywithoutactionmapper" ,
18151859 "InternalBookNBS" ,
18161860 {},
18171861 SuggestedActions ([]),
18181862 ),
18191863 (
18201864 """Rule match: default_comms_routing has multiple values,
1821- one of the value is invalid, valid values should be returned in actions""" ,
1865+ one of the value is invalid, valid values should be returned in actions""" ,
18221866 "defaultcomms1|invaliddefault" ,
18231867 None ,
18241868 {"defaultcomms1" : default_comms_detail },
0 commit comments