@@ -233,3 +233,39 @@ def test_validate_iterations_non_empty(self, valid_campaign_config_with_only_man
233233 CampaignConfigValidation (** data )
234234 errors = error .value .errors ()
235235 assert any (e ["loc" ][- 1 ] == "Iterations" for e in errors ), "Expected validation error on 'Iterations'"
236+
237+ def test_actions_mapper_has_default_comms_routing_key (self , valid_campaign_config_with_only_mandatory_fields ):
238+ expected_action = {
239+ "ExternalRoutingCode" : "BookLocal" ,
240+ "ActionDescription" : "##Getting the vaccine\n "
241+ "You can get an RSV vaccination at your GP surgery.\n "
242+ "Your GP surgery may contact you about getting the RSV vaccine. "
243+ "This may be by letter, text, phone call, email or through the NHS App. "
244+ "You do not need to wait to be contacted before booking your vaccination." ,
245+ "ActionType" : "InfoText"
246+ }
247+
248+ config = {** valid_campaign_config_with_only_mandatory_fields }
249+ config ["Iterations" ][0 ]["DefaultCommsRouting" ] = "BOOK_LOCAL"
250+ config ["Iterations" ][0 ]["ActionsMapper" ] = {
251+ "BOOK_LOCAL" : expected_action
252+ }
253+
254+ # Should not raise error
255+ CampaignConfigValidation (** config )
256+
257+ def test_actions_mapper_missing_default_comms_routing_key (self , valid_campaign_config_with_only_mandatory_fields ):
258+ config = {** valid_campaign_config_with_only_mandatory_fields }
259+ config ["Iterations" ][0 ]["DefaultCommsRouting" ] = "BOOK_LOCAL"
260+ config ["Iterations" ][0 ]["ActionsMapper" ] = {} # Missing BOOK_LOCAL
261+
262+ with pytest .raises (ValidationError ) as error :
263+ CampaignConfigValidation (** config )
264+
265+ errors = error .value .errors ()
266+ assert any (
267+ e ["loc" ][- 1 ] == "ActionsMapper" and "BOOK_LOCAL" in str (e ["msg" ])
268+ for e in errors
269+ ), "Expected validation error for missing BOOK_LOCAL entry in ActionsMapper"
270+
271+
0 commit comments