2121 Status ,
2222 SuggestedAction ,
2323 UrlLabel ,
24- UrlLink ,
24+ UrlLink , InternalActionCode ,
2525)
2626from eligibility_signposting_api .model .rules import ActionsMapper , AvailableAction
2727from eligibility_signposting_api .services .calculators .eligibility_calculator import EligibilityCalculator
@@ -614,11 +614,25 @@ def test_multiple_conditions_where_both_are_actionable(faker: Faker):
614614 is_condition ()
615615 .with_condition_name (ConditionName ("RSV" ))
616616 .and_status (Status .actionable )
617- .and_actions ([suggested_action_for_default_comms ]),
617+ .and_actions ([SuggestedAction (
618+ internal_action_code = InternalActionCode ("defaultcomms" ),
619+ action_type = ActionType ("CareCardWithText" ),
620+ action_code = ActionCode ("BookLocal" ),
621+ action_description = ActionDescription ("You can get an RSV vaccination at your GP surgery" ),
622+ url_link = None ,
623+ url_label = None ,
624+ )]),
618625 is_condition ()
619626 .with_condition_name (ConditionName ("COVID" ))
620627 .and_status (Status .actionable )
621- .and_actions ([suggested_action_for_book_nbs ]),
628+ .and_actions ([SuggestedAction (
629+ internal_action_code = InternalActionCode ("ActionCode1" ),
630+ action_type = ActionType ("ButtonAuthLink" ),
631+ action_code = ActionCode ("BookNBS" ),
632+ action_description = ActionDescription ("Action description" ),
633+ url_link = UrlLink (HttpUrl ("https://www.nhs.uk/book-rsv" )),
634+ url_label = UrlLabel ("Continue to booking" ),
635+ )]),
622636 )
623637 ),
624638 )
@@ -1738,7 +1752,7 @@ def test_cohort_group_descriptions_pick_first_non_empty_if_available(
17381752 ActionType = "ButtonAuthLink" ,
17391753 ExternalRoutingCode = "BookNBS" ,
17401754 ActionDescription = "Action description" ,
1741- UrlLink = "http ://www.nhs.uk/book-rsv" ,
1755+ UrlLink = HttpUrl ( "https ://www.nhs.uk/book-rsv") ,
17421756 UrlLabel = "Continue to booking" ,
17431757)
17441758
@@ -1748,23 +1762,6 @@ def test_cohort_group_descriptions_pick_first_non_empty_if_available(
17481762 ActionDescription = "You can get an RSV vaccination at your GP surgery" ,
17491763)
17501764
1751- suggested_action_for_book_nbs = SuggestedAction (
1752- action_type = ActionType (book_nbs_comms .action_type ),
1753- action_code = ActionCode (book_nbs_comms .action_code ),
1754- action_description = ActionDescription (book_nbs_comms .action_description ),
1755- url_link = UrlLink (book_nbs_comms .url_link ),
1756- url_label = UrlLabel (book_nbs_comms .url_label ),
1757- )
1758-
1759- suggested_action_for_default_comms = SuggestedAction (
1760- action_type = ActionType (default_comms_detail .action_type ),
1761- action_code = ActionCode (default_comms_detail .action_code ),
1762- action_description = ActionDescription (default_comms_detail .action_description ),
1763- url_link = None ,
1764- url_label = None ,
1765- )
1766-
1767-
17681765@pytest .mark .parametrize (
17691766 ("test_comment" , "default_comms_routing" , "comms_routing" , "actions_mapper" , "expected_actions" ),
17701767 [
@@ -1774,39 +1771,81 @@ def test_cohort_group_descriptions_pick_first_non_empty_if_available(
17741771 "defaultcomms" ,
17751772 "InternalBookNBS" ,
17761773 {"InternalBookNBS" : book_nbs_comms , "defaultcomms" : default_comms_detail },
1777- [suggested_action_for_book_nbs ],
1774+ [SuggestedAction (
1775+ internal_action_code = InternalActionCode ("InternalBookNBS" ),
1776+ action_type = ActionType ("ButtonAuthLink" ),
1777+ action_code = ActionCode ("BookNBS" ),
1778+ action_description = ActionDescription ("Action description" ),
1779+ url_link = UrlLink (HttpUrl ("https://www.nhs.uk/book-rsv" )),
1780+ url_label = UrlLabel ("Continue to booking" ),
1781+ )],
17781782 ),
17791783 (
17801784 """Rule match: default_comms_routing has multiple values,
17811785 comms missing in rule, all default comms should be returned in actions""" ,
17821786 "defaultcomms1|defaultcomms2" ,
17831787 None ,
17841788 {"defaultcomms1" : default_comms_detail , "defaultcomms2" : default_comms_detail },
1785- [suggested_action_for_default_comms , suggested_action_for_default_comms ],
1789+ [SuggestedAction (
1790+ internal_action_code = InternalActionCode ("defaultcomms1" ),
1791+ action_type = ActionType ("CareCardWithText" ),
1792+ action_code = ActionCode ("BookLocal" ),
1793+ action_description = ActionDescription ("You can get an RSV vaccination at your GP surgery" ),
1794+ url_link = None ,
1795+ url_label = None ,
1796+ ), SuggestedAction (
1797+ internal_action_code = InternalActionCode ("defaultcomms2" ),
1798+ action_type = ActionType ("CareCardWithText" ),
1799+ action_code = ActionCode ("BookLocal" ),
1800+ action_description = ActionDescription ("You can get an RSV vaccination at your GP surgery" ),
1801+ url_link = None ,
1802+ url_label = None ,
1803+ )],
17861804 ),
17871805 (
17881806 """Rule match: default_comms_routing has multiple values,
17891807 comms is empty string, all default comms should be returned in actions""" ,
17901808 "defaultcomms1" ,
17911809 "" ,
17921810 {"defaultcomms1" : default_comms_detail },
1793- [suggested_action_for_default_comms ],
1811+ [SuggestedAction (
1812+ internal_action_code = InternalActionCode ("defaultcomms1" ),
1813+ action_type = ActionType ("CareCardWithText" ),
1814+ action_code = ActionCode ("BookLocal" ),
1815+ action_description = ActionDescription ("You can get an RSV vaccination at your GP surgery" ),
1816+ url_link = None ,
1817+ url_label = None ,
1818+ )],
17941819 ),
17951820 (
17961821 """Rule match: default_comms_routing present,
17971822 action_mapper missing for matching comms, return default_comms in actions""" ,
17981823 "defaultcomms" ,
17991824 "InternalBookNBS" ,
18001825 {"defaultcomms" : default_comms_detail },
1801- [suggested_action_for_default_comms ],
1826+ [SuggestedAction (
1827+ internal_action_code = InternalActionCode ("defaultcomms" ),
1828+ action_type = ActionType ("CareCardWithText" ),
1829+ action_code = ActionCode ("BookLocal" ),
1830+ action_description = ActionDescription ("You can get an RSV vaccination at your GP surgery" ),
1831+ url_link = None ,
1832+ url_label = None ,
1833+ )],
18021834 ),
18031835 (
18041836 """Rule match: default_comms_routing present,
18051837 rule has an incorrect comms key, return default_comms in actions""" ,
18061838 "defaultcomms" ,
18071839 "InvalidCode" ,
18081840 {"defaultcomms" : default_comms_detail },
1809- [suggested_action_for_default_comms ],
1841+ [SuggestedAction (
1842+ internal_action_code = InternalActionCode ("defaultcomms" ),
1843+ action_type = ActionType ("CareCardWithText" ),
1844+ action_code = ActionCode ("BookLocal" ),
1845+ action_description = ActionDescription ("You can get an RSV vaccination at your GP surgery" ),
1846+ url_link = None ,
1847+ url_label = None ,
1848+ )],
18101849 ),
18111850 (
18121851 """Rule match: action_mapper present without url,
@@ -1822,6 +1861,7 @@ def test_cohort_group_descriptions_pick_first_non_empty_if_available(
18221861 },
18231862 [
18241863 SuggestedAction (
1864+ internal_action_code = InternalActionCode ("InternalBookNBS" ),
18251865 action_type = ActionType (book_nbs_comms .action_type ),
18261866 action_code = ActionCode (book_nbs_comms .action_code ),
18271867 action_description = ActionDescription (book_nbs_comms .action_description ),
@@ -1844,7 +1884,14 @@ def test_cohort_group_descriptions_pick_first_non_empty_if_available(
18441884 "" ,
18451885 "InternalBookNBS" ,
18461886 {"InternalBookNBS" : book_nbs_comms },
1847- [suggested_action_for_book_nbs ],
1887+ [SuggestedAction (
1888+ internal_action_code = InternalActionCode ("InternalBookNBS" ),
1889+ action_type = ActionType ("ButtonAuthLink" ),
1890+ action_code = ActionCode ("BookNBS" ),
1891+ action_description = ActionDescription ("Action description" ),
1892+ url_link = UrlLink (HttpUrl ("https://www.nhs.uk/book-rsv" )),
1893+ url_label = UrlLabel ("Continue to booking" ),
1894+ )],
18481895 ),
18491896 (
18501897 """Rule match: default_comms_routing present,
@@ -1860,7 +1907,14 @@ def test_cohort_group_descriptions_pick_first_non_empty_if_available(
18601907 "defaultcomms1|invaliddefault" ,
18611908 None ,
18621909 {"defaultcomms1" : default_comms_detail },
1863- [suggested_action_for_default_comms ],
1910+ [SuggestedAction (
1911+ internal_action_code = InternalActionCode ("defaultcomms1" ),
1912+ action_type = ActionType ("CareCardWithText" ),
1913+ action_code = ActionCode ("BookLocal" ),
1914+ action_description = ActionDescription ("You can get an RSV vaccination at your GP surgery" ),
1915+ url_link = None ,
1916+ url_label = None ,
1917+ )],
18641918 ),
18651919 ],
18661920)
@@ -1963,7 +2017,14 @@ def test_cohort_label_not_supported_used_in_r_rules(test_comment: str, redirect_
19632017 is_condition ()
19642018 .with_condition_name (ConditionName ("RSV" ))
19652019 .and_status (equal_to (Status .actionable ))
1966- .and_actions (equal_to ([suggested_action_for_book_nbs ]))
2020+ .and_actions (equal_to ([SuggestedAction (
2021+ internal_action_code = InternalActionCode ("ActionCode1" ),
2022+ action_type = ActionType ("ButtonAuthLink" ),
2023+ action_code = ActionCode ("BookNBS" ),
2024+ action_description = ActionDescription ("Action description" ),
2025+ url_link = UrlLink (HttpUrl ("https://www.nhs.uk/book-rsv" )),
2026+ url_label = UrlLabel ("Continue to booking" ),
2027+ )]))
19672028 )
19682029 ),
19692030 test_comment ,
@@ -2019,7 +2080,14 @@ def test_multiple_r_rules_match_with_same_priority(faker: Faker):
20192080 is_condition ()
20202081 .with_condition_name (ConditionName ("RSV" ))
20212082 .and_status (equal_to (Status .actionable ))
2022- .and_actions (equal_to ([suggested_action_for_book_nbs ]))
2083+ .and_actions (equal_to ([SuggestedAction (
2084+ internal_action_code = InternalActionCode ("rule_1_comms_routing" ),
2085+ action_type = ActionType ("ButtonAuthLink" ),
2086+ action_code = ActionCode ("BookNBS" ),
2087+ action_description = ActionDescription ("Action description" ),
2088+ url_link = UrlLink (HttpUrl ("https://www.nhs.uk/book-rsv" )),
2089+ url_label = UrlLabel ("Continue to booking" ),
2090+ )]))
20232091 )
20242092 ),
20252093 )
@@ -2073,7 +2141,14 @@ def test_multiple_r_rules_with_same_priority_one_rule_mismatch_should_return_def
20732141 is_condition ()
20742142 .with_condition_name (ConditionName ("RSV" ))
20752143 .and_status (equal_to (Status .actionable ))
2076- .and_actions (equal_to ([suggested_action_for_default_comms ]))
2144+ .and_actions (equal_to ([SuggestedAction (
2145+ internal_action_code = InternalActionCode ("defaultcomms" ),
2146+ action_type = ActionType ("CareCardWithText" ),
2147+ action_code = ActionCode ("BookLocal" ),
2148+ action_description = ActionDescription ("You can get an RSV vaccination at your GP surgery" ),
2149+ url_link = None ,
2150+ url_label = None ,
2151+ )]))
20772152 )
20782153 ),
20792154 )
@@ -2103,7 +2178,7 @@ def test_only_highest_priority_rule_is_applied_and_return_actions_only_for_that_
21032178 ActionType = "AuthLink" ,
21042179 ExternalRoutingCode = "BookNBS" ,
21052180 ActionDescription = "Action description" ,
2106- UrlLink = "http ://www.nhs.uk/book-rsv" ,
2181+ UrlLink = HttpUrl ( "https ://www.nhs.uk/book-rsv") ,
21072182 UrlLabel = "Continue to booking" ,
21082183 ),
21092184 "defaultcomms" : default_comms_detail ,
@@ -2125,6 +2200,7 @@ def test_only_highest_priority_rule_is_applied_and_return_actions_only_for_that_
21252200 actual = calculator .evaluate_eligibility ()
21262201
21272202 expected_actions = SuggestedAction (
2203+ internal_action_code = InternalActionCode ("rule_1_comms_routing" ),
21282204 action_type = ActionType ("ButtonAuthLink" ),
21292205 action_code = ActionCode ("BookNBS" ),
21302206 action_description = ActionDescription ("Action description" ),
@@ -2187,7 +2263,14 @@ def test_should_include_actions_when_include_actions_flag_is_true_when_status_is
21872263 is_condition ()
21882264 .with_condition_name (ConditionName ("RSV" ))
21892265 .and_status (equal_to (Status .actionable ))
2190- .and_actions (equal_to ([suggested_action_for_book_nbs ]))
2266+ .and_actions (equal_to ([SuggestedAction (
2267+ internal_action_code = InternalActionCode ("book_nbs" ),
2268+ action_type = ActionType ("ButtonAuthLink" ),
2269+ action_code = ActionCode ("BookNBS" ),
2270+ action_description = ActionDescription ("Action description" ),
2271+ url_link = UrlLink (HttpUrl ("https://www.nhs.uk/book-rsv" )),
2272+ url_label = UrlLabel ("Continue to booking" ),
2273+ )]))
21912274 )
21922275 ),
21932276 )
0 commit comments