Skip to content

Commit 47e6fc6

Browse files
Maffoochclaude
andcommitted
Fix ruff D213 and skip dispatch during fixture loads
- Reformat async_create_notification importer-guard docstring to D213 style - Skip post_save dispatch when raw=True (loaddata) so the k8s initializer's fixture install path doesn't require an available Celery broker. Without this guard the unconditional async dispatch tries to enqueue during product_type.json load and fails with kombu OperationalError. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7b9dd9d commit 47e6fc6

4 files changed

Lines changed: 11 additions & 1 deletion

File tree

dojo/engagement/signals.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
@receiver(post_save, sender=Engagement)
1919
def engagement_post_save(sender, instance, created, **kwargs):
20+
# raw=True is set by loaddata; skip dispatch so fixture loading doesn't require a live broker.
21+
if kwargs.get("raw"):
22+
return
2023
if created:
2124
title = _('Engagement created for "%(product)s": %(name)s') % {"product": instance.product, "name": instance.name}
2225
dojo_dispatch_task(

dojo/product/signals.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
@receiver(post_save, sender=Product)
2121
def product_post_save(sender, instance, created, **kwargs):
22+
# raw=True is set by loaddata; skip dispatch so fixture loading doesn't require a live broker.
23+
if kwargs.get("raw"):
24+
return
2225
if created:
2326
dojo_dispatch_task(
2427
async_create_notification,

dojo/product_type/signals.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
@receiver(post_save, sender=Product_Type)
2121
def product_type_post_save(sender, instance, created, **kwargs):
22+
# raw=True is set by loaddata; skip dispatch so fixture loading doesn't require a live broker.
23+
if kwargs.get("raw"):
24+
return
2225
if created:
2326
dojo_dispatch_task(
2427
async_create_notification,

unittests/test_notifications.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,8 @@ def test_product_type_added_dispatches_async(self, mock_dispatch):
602602
self.assertNotIn("product_type", kwargs)
603603

604604
def test_importer_dispatch_uses_id_kwargs(self):
605-
"""Static check that default_importer's test_added dispatch passes *_id kwargs (not model instances).
605+
"""
606+
Static check that default_importer's test_added dispatch passes *_id kwargs (not model instances).
606607
607608
The importer's notification dispatch fires deep inside a full scan-import flow;
608609
exercising it end-to-end is covered by integration tests. This guard test

0 commit comments

Comments
 (0)