Skip to content

Commit b339824

Browse files
fix(tests): prevent tag inheritance tests from polluting production Celery queue (#14493)
product_tags_post_add_remove dispatches propagate_tags_on_product via dojo_dispatch_task. When the signal fires outside a request context (e.g. during test setUp), get_current_user() returns None, so we_want_async() always returns True regardless of block_execution — the task goes to the shared Redis queue. The real Celery worker then picks it up and runs against the live database, causing multi-hour tag propagation runs over large products. Fix: add @override_settings(CELERY_TASK_ALWAYS_EAGER=True) to the three test classes that enable system-wide product tag inheritance. This makes Celery run tasks inline in the test process, keeping tasks off the shared Redis queue and ensuring assertions see propagated tags.
1 parent e039b0b commit b339824

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

unittests/test_tags.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from django.conf import settings
66
from django.contrib.auth.models import User
7-
from django.test import Client
7+
from django.test import Client, override_settings
88
from django.urls import reverse
99

1010
from dojo.models import Finding, Product, Test
@@ -454,6 +454,7 @@ def reimport_scan_with_params(self, test_id, filename, scan_type="ZAP Scan", min
454454
return {"test": new_test_id}
455455

456456

457+
@override_settings(CELERY_TASK_ALWAYS_EAGER=True)
457458
@versioned_fixtures
458459
class InheritedTagsTests(DojoAPITestCase):
459460

@@ -610,6 +611,7 @@ def test_remove_tag_from_product_then_add_tag_to_product(self):
610611
self.assertEqual(product_tags_post_addition, self._convert_instance_tags_to_list(objects.get("finding")))
611612

612613

614+
@override_settings(CELERY_TASK_ALWAYS_EAGER=True)
613615
@versioned_fixtures
614616
class InheritedTagsImportTestAPI(DojoAPITestCase, InheritedTagsImportMixin):
615617

@@ -626,6 +628,7 @@ def setUp(self):
626628
InheritedTagsImportMixin.setUp(self)
627629

628630

631+
@override_settings(CELERY_TASK_ALWAYS_EAGER=True)
629632
@versioned_fixtures
630633
class InheritedTagsImportTestUI(DojoAPITestCase, InheritedTagsImportMixin):
631634

0 commit comments

Comments
 (0)