Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Merge branch 'master' into deprecate_checkout_quantity_changed_webhook_event

Maciej Korycinski63d351cba2b1
diff --cc saleor/plugins/webhook/tests/test_webhook.py
index d1e2a1264e,96c47864ce..e9d2f253ea
--- a/saleor/plugins/webhook/tests/test_webhook.py
+++ b/saleor/plugins/webhook/tests/test_webhook.py
@@@ -218,25 -219,37 +219,61 @@@ def test_checkout_quantity_changed
)
[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_for_event.delay")
+def test_checkout_created(mocked_webhook_trigger, settings, checkout_with_items):
+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]
+ manager = get_plugins_manager()
+ manager.checkout_created(checkout_with_items)
+
+ expected_data = generate_checkout_payload(checkout_with_items)
+ mocked_webhook_trigger.assert_called_once_with(
+ WebhookEventType.CHECKOUT_CREATED, expected_data
+ )
+
+
[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_for_event.delay")
+def test_checkout_updated(mocked_webhook_trigger, settings, checkout_with_items):
+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]
+ manager = get_plugins_manager()
+ manager.checkout_updated(checkout_with_items)
+
+ expected_data = generate_checkout_payload(checkout_with_items)
+ mocked_webhook_trigger.assert_called_once_with(
+ WebhookEventType.CHECKOUT_UPADTED, expected_data
+ )
++
++
+ @mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_for_event.delay")
+ def test_invoice_request(mocked_webhook_trigger, settings, fulfilled_order):
+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]
+ manager = get_plugins_manager()
+ invoice = fulfilled_order.invoices.first()
+ manager.invoice_request(fulfilled_order, invoice, invoice.number)
+ expected_data = generate_invoice_payload(invoice)
+ mocked_webhook_trigger.assert_called_once_with(
+ WebhookEventType.INVOICE_REQUESTED, expected_data
+ )
+
+
+ @mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_for_event.delay")
+ def test_invoice_delete(mocked_webhook_trigger, settings, fulfilled_order):
+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]
+ manager = get_plugins_manager()
+ invoice = fulfilled_order.invoices.first()
+ manager.invoice_delete(invoice)
+ expected_data = generate_invoice_payload(invoice)
+ mocked_webhook_trigger.assert_called_once_with(
+ WebhookEventType.INVOICE_DELETED, expected_data
+ )
+
+
+ @mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_for_event.delay")
+ def test_invoice_sent(mocked_webhook_trigger, settings, fulfilled_order):
+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]
+ manager = get_plugins_manager()
+ invoice = fulfilled_order.invoices.first()
+ manager.invoice_sent(invoice, fulfilled_order.user.email)
+ expected_data = generate_invoice_payload(invoice)
+ mocked_webhook_trigger.assert_called_once_with(
+ WebhookEventType.INVOICE_SENT, expected_data
+ )
diff --cc saleor/webhook/event_types.py
index 1caca8c954,0b8601e4d2..a0ad1c979a
--- a/saleor/webhook/event_types.py
+++ b/saleor/webhook/event_types.py
@@@ -33,12 -33,12 +37,15 @@@ class WebhookEventType
ORDER_UPDATED: "Order updated",
ORDER_CANCELLED: "Order cancelled",
ORDER_FULFILLED: "Order fulfilled",
+ INVOICE_REQUESTED: "Invoice requested",
+ INVOICE_DELETED: "Invoice deleted",
+ INVOICE_SENT: "Invoice sent",
CUSTOMER_CREATED: "Customer created",
PRODUCT_CREATED: "Product created",
+ # CHECKOUT_QUANTITY_CHANGED is deprecated. It will be removed in Saleor 3.0
CHECKOUT_QUANTITY_CHANGED: "Checkout quantity changed",
+ CHECKOUT_CREATED: "Checkout created",
+ CHECKOUT_UPADTED: "Checkout updated",
FULFILLMENT_CREATED: "Fulfillment_created",
}
@@@ -49,12 -49,12 +56,15 @@@
(ORDER_UPDATED, DISPLAY_LABELS[ORDER_UPDATED]),
(ORDER_CANCELLED, DISPLAY_LABELS[ORDER_CANCELLED]),
(ORDER_FULFILLED, DISPLAY_LABELS[ORDER_FULFILLED]),
+ (INVOICE_REQUESTED, DISPLAY_LABELS[INVOICE_REQUESTED]),
+ (INVOICE_DELETED, DISPLAY_LABELS[INVOICE_DELETED]),
+ (INVOICE_SENT, DISPLAY_LABELS[INVOICE_SENT]),
(CUSTOMER_CREATED, DISPLAY_LABELS[CUSTOMER_CREATED]),
(PRODUCT_CREATED, DISPLAY_LABELS[PRODUCT_CREATED]),
+ # CHECKOUT_QUANTITY_CHANGED is deprecated. It will be removed in Saleor 3.0
(CHECKOUT_QUANTITY_CHANGED, DISPLAY_LABELS[CHECKOUT_QUANTITY_CHANGED]),
+ (CHECKOUT_CREATED, DISPLAY_LABELS[CHECKOUT_CREATED]),
+ (CHECKOUT_UPADTED, DISPLAY_LABELS[CHECKOUT_UPADTED]),
(FULFILLMENT_CREATED, DISPLAY_LABELS[FULFILLMENT_CREATED]),
]