55from swo_aws_extension .flows .order import PurchaseContext
66from swo_aws_extension .flows .order_utils import (
77 set_order_template ,
8- switch_order_status_to_complete_and_notify ,
9- switch_order_status_to_failed_and_notify ,
10- switch_order_status_to_process_and_notify ,
11- switch_order_status_to_query_and_notify ,
8+ switch_order_status_to_complete ,
9+ switch_order_status_to_failed ,
10+ switch_order_status_to_process ,
11+ switch_order_status_to_query ,
1212 update_processing_template_and_notify ,
1313)
1414
@@ -50,19 +50,15 @@ def test_switch_order_to_query_and_notify(
5050 "swo_aws_extension.flows.order_utils.query_order" ,
5151 return_value = order ,
5252 )
53- notification_mock = mocker .patch (
54- "swo_aws_extension.flows.order_utils.MPTNotificationManager" ,
55- )
5653
57- switch_order_status_to_query_and_notify (client , context , "TemplateName" ) # act
54+ switch_order_status_to_query (client , context , "TemplateName" ) # act
5855
5956 query_order_mock .assert_called_with (
6057 client ,
6158 context .order_id ,
6259 parameters = context .order ["parameters" ],
6360 template = new_template ,
6461 )
65- notification_mock .assert_called_once ()
6662
6763
6864def test_switch_order_to_query_and_notify_error (
@@ -86,11 +82,8 @@ def test_switch_order_to_query_and_notify_error(
8682 "swo_aws_extension.flows.order_utils.query_order" ,
8783 return_value = context .order ,
8884 )
89- notification_mock = mocker .patch (
90- "swo_aws_extension.flows.order_utils.MPTNotificationManager" ,
91- )
9285
93- switch_order_status_to_query_and_notify (client , context , "TemplateName" ) # act
86+ switch_order_status_to_query (client , context , "TemplateName" ) # act
9487
9588 query_order_mock .assert_called_with (
9689 client ,
@@ -99,30 +92,26 @@ def test_switch_order_to_query_and_notify_error(
9992 template = new_template ,
10093 error = context .order ["error" ],
10194 )
102- notification_mock .assert_called_once ()
10395
10496
105- def test_switch_order_to_failed_and_notify (mocker , order_factory , fulfillment_parameters_factory ):
97+ def test_switch_order_to_failed (mocker , order_factory , fulfillment_parameters_factory ):
10698 client = mocker .MagicMock (spec = MPTClient )
10799 order = order_factory (fulfillment_parameters = fulfillment_parameters_factory ())
108100 context = PurchaseContext .from_order_data (order )
109101 fail_order_mock = mocker .patch (
110102 "swo_aws_extension.flows.order_utils.fail_order" ,
111103 return_value = order ,
112- )
113- notification_mock = mocker .patch (
114- "swo_aws_extension.flows.order_utils.MPTNotificationManager" ,
104+ autospec = True ,
115105 )
116106
117- switch_order_status_to_failed_and_notify (client , context , "Failure reason" ) # act
107+ switch_order_status_to_failed (client , context , "Failure reason" ) # act
118108
119109 fail_order_mock .assert_called_with (
120110 client ,
121111 context .order_id ,
122112 "Failure reason" ,
123113 parameters = context .order ["parameters" ],
124114 )
125- notification_mock .assert_called_once ()
126115
127116
128117def test_switch_order_to_process_and_notify (
@@ -142,19 +131,15 @@ def test_switch_order_to_process_and_notify(
142131 "swo_aws_extension.flows.order_utils.process_order" ,
143132 return_value = order ,
144133 )
145- notification_mock = mocker .patch (
146- "swo_aws_extension.flows.order_utils.MPTNotificationManager" ,
147- )
148134
149- switch_order_status_to_process_and_notify (mpt_client , context , "TemplateName" ) # act
135+ switch_order_status_to_process (mpt_client , context , "TemplateName" ) # act
150136
151137 process_order_mock .assert_called_once_with (
152138 mpt_client ,
153139 context .order_id ,
154140 parameters = context .order ["parameters" ],
155141 template = new_template ,
156142 )
157- notification_mock .assert_called_once ()
158143
159144
160145def test_switch_order_to_process_and_notify_error (
@@ -178,7 +163,7 @@ def test_switch_order_to_process_and_notify_error(
178163 "swo_aws_extension.flows.order_utils.MPTNotificationManager" ,
179164 )
180165
181- switch_order_status_to_process_and_notify (mpt_client , context , "TemplateName" ) # act
166+ switch_order_status_to_process (mpt_client , context , "TemplateName" ) # act
182167
183168 notification_mock .assert_not_called ()
184169
@@ -194,24 +179,20 @@ def test_switch_order_status_to_complete(
194179 return_value = new_template ,
195180 )
196181 order = order_factory (template = default_template )
197- notification_mock = mocker .patch (
198- "swo_aws_extension.flows.order_utils.MPTNotificationManager" ,
199- )
200182 context = PurchaseContext .from_order_data (order )
201183 complete_order_mock = mocker .patch (
202184 "swo_aws_extension.flows.order_utils.complete_order" ,
203185 return_value = order ,
204186 )
205187
206- switch_order_status_to_complete_and_notify (client , context , "TemplateName" ) # act
188+ switch_order_status_to_complete (client , context , "TemplateName" ) # act
207189
208190 complete_order_mock .assert_called_with (
209191 client ,
210192 context .order_id ,
211193 parameters = context .order ["parameters" ],
212194 template = new_template ,
213195 )
214- notification_mock .assert_called_once ()
215196
216197
217198def test_update_processing_template_and_notify (
0 commit comments