def test_notify_on_quote_cancelled(self, mocked_notify_client): """Test that a notification is triggered when a quote is cancelled.""" order = OrderWithOpenQuoteFactory(assignees=[]) OrderAssigneeFactory.create_batch(1, order=order) OrderSubscriberFactory.create_batch(2, order=order) mocked_notify_client.reset_mock() order.reopen(by=AdviserFactory()) # 1 = customer, 3 = assignees/subscribers assert len( mocked_notify_client.send_email_notification.call_args_list) == ( 3 + 1) templates_called = [ data[1]['template_id'] for data in mocked_notify_client.send_email_notification.call_args_list ] assert templates_called == [ Template.quote_cancelled_for_customer.value, Template.quote_cancelled_for_adviser.value, Template.quote_cancelled_for_adviser.value, Template.quote_cancelled_for_adviser.value, ]
def test_with_active_quote(self): """ Test that if an order with an active quote is reopened, the quote is cancelled. """ order = OrderWithOpenQuoteFactory() assert not order.quote.is_cancelled() adviser = AdviserFactory() with freeze_time('2017-07-12 13:00'): order.reopen(by=adviser) assert order.quote.is_cancelled() assert order.quote.cancelled_by == adviser assert order.quote.cancelled_on == now() assert order.status == OrderStatus.draft