|
5 | 5 | QueryIfInvalid, |
6 | 6 | ResetOrderErrors, |
7 | 7 | SetupAgreementExternalId, |
| 8 | + StartOrderProcessing, |
8 | 9 | ) |
9 | 10 | from ffc.parameters import PARAM_PHASE_ORDERING |
10 | 11 |
|
@@ -193,3 +194,87 @@ def test_reset_order_error( |
193 | 194 | for param in ctx.order["parameters"][PARAM_PHASE_ORDERING] |
194 | 195 | ), |
195 | 196 | ) |
| 197 | + |
| 198 | + |
| 199 | +def test_start_order_processing_same_template( |
| 200 | + mocker, |
| 201 | + mocked_next_step, |
| 202 | + mpt_client, |
| 203 | + processing_purchase_order, |
| 204 | + template, |
| 205 | +): |
| 206 | + processing_purchase_order["template"] = template |
| 207 | + mocker.patch( |
| 208 | + "ffc.flows.steps.order.get_product_template_or_default", |
| 209 | + return_value=template, |
| 210 | + ) |
| 211 | + mocked_update_order = mocker.patch("ffc.flows.steps.order.update_order") |
| 212 | + mocked_send_email_notification = mocker.patch( |
| 213 | + "ffc.flows.steps.order.send_email_notification" |
| 214 | + ) |
| 215 | + ctx = OrderContext(order=processing_purchase_order) |
| 216 | + step = StartOrderProcessing("Purchase") |
| 217 | + |
| 218 | + step(mpt_client, ctx, mocked_next_step) |
| 219 | + |
| 220 | + mocked_next_step.assert_called_once() |
| 221 | + mocked_update_order.assert_not_called() |
| 222 | + mocked_send_email_notification.assert_not_called() |
| 223 | + |
| 224 | + |
| 225 | +def test_start_order_processing( |
| 226 | + mocker, |
| 227 | + mocked_next_step, |
| 228 | + mpt_client, |
| 229 | + processing_purchase_order, |
| 230 | + template, |
| 231 | +): |
| 232 | + mocker.patch( |
| 233 | + "ffc.flows.steps.order.get_product_template_or_default", |
| 234 | + return_value=template, |
| 235 | + ) |
| 236 | + mocked_update_order = mocker.patch("ffc.flows.steps.order.update_order") |
| 237 | + mocked_send_email_notification = mocker.patch( |
| 238 | + "ffc.flows.steps.order.send_email_notification" |
| 239 | + ) |
| 240 | + ctx = OrderContext(order=processing_purchase_order) |
| 241 | + step = StartOrderProcessing("Purchase") |
| 242 | + |
| 243 | + step(mpt_client, ctx, mocked_next_step) |
| 244 | + |
| 245 | + mocked_next_step.assert_called_once() |
| 246 | + mocked_update_order.assert_called_once_with( |
| 247 | + mpt_client, |
| 248 | + processing_purchase_order["id"], |
| 249 | + template=template, |
| 250 | + ) |
| 251 | + mocked_send_email_notification.assert_not_called() |
| 252 | + |
| 253 | + |
| 254 | +def test_start_order_processing_send_notification( |
| 255 | + mocker, |
| 256 | + mocked_next_step, |
| 257 | + mpt_client, |
| 258 | + first_attempt_processing_purchase_order, |
| 259 | + template, |
| 260 | +): |
| 261 | + first_attempt_processing_purchase_order["template"] = template |
| 262 | + mocker.patch( |
| 263 | + "ffc.flows.steps.order.get_product_template_or_default", |
| 264 | + return_value=template, |
| 265 | + ) |
| 266 | + mocked_update_order = mocker.patch("ffc.flows.steps.order.update_order") |
| 267 | + mocked_send_email_notification = mocker.patch( |
| 268 | + "ffc.flows.steps.order.send_email_notification" |
| 269 | + ) |
| 270 | + ctx = OrderContext(order=first_attempt_processing_purchase_order) |
| 271 | + step = StartOrderProcessing("Purchase") |
| 272 | + |
| 273 | + step(mpt_client, ctx, mocked_next_step) |
| 274 | + |
| 275 | + mocked_next_step.assert_called_once() |
| 276 | + mocked_update_order.assert_not_called() |
| 277 | + mocked_send_email_notification.assert_called_once_with( |
| 278 | + mpt_client, |
| 279 | + first_attempt_processing_purchase_order, |
| 280 | + ) |
0 commit comments