def test_no_notification_on_order_updated(self): """Test that no notification is triggered when saving an order.""" order = OrderFactory() notify.client.reset_mock() order.description = 'new description' order.save() assert not notify.client.send_email_notification.called
def test_doesnt_save_if_pricing_didnt_change(self): """ Test that if the pricing didn't change, update_order_pricing doesn't do anything. """ order = OrderFactory() with mock.patch.object(order, 'save') as mocked_save: assert order.total_cost > 0 order.description = 'updated description' update_order_pricing(order, commit=True) assert not mocked_save.called
def test_updating_order_updates_opensearch(opensearch_with_signals): """Test that when I update an order, the updated version gets synced to ES.""" order = OrderFactory() new_description = 'lorem' order.description = new_description order.save() opensearch_with_signals.indices.refresh() result = opensearch_with_signals.get( index=OrderSearchApp.search_model.get_write_index(), id=order.pk, ) assert result['_source']['description'] == new_description
def test_updating_order_updates_es(setup_es): """Test that when I update an order, the updated version gets synced to ES.""" order = OrderFactory() new_description = 'lorem' order.description = new_description order.save() setup_es.indices.refresh() result = setup_es.get( index=OrderSearchApp.es_model.get_write_index(), doc_type=OrderSearchApp.name, id=order.pk, ) assert result['_source']['description'] == new_description
def test_pricing_unchanged_if_update_unrelated(self): """ Test that if an unrelated field gets updated, the pricing stays the same. """ order = OrderFactory() pre_update_pricing = get_pricing_from_order(order) order.description = 'updated description' order.save() order.refresh_from_db() post_update_pricing = get_pricing_from_order(order) assert pre_update_pricing == post_update_pricing