From 218f4d7b124bd102dc61d69a934d064ed31530dc Mon Sep 17 00:00:00 2001 From: Nima Akbarzadeh Date: Sat, 4 Oct 2025 00:22:23 +0200 Subject: [PATCH] fix(tests): Replace direct Model.objects.create with factory method Replace DetectorGroup.objects.create() with create_detector_group() factory method in test_organization_open_periods.py to comply with Sentry testing standards. The test was violating the mandatory Python testing rule that prohibits direct Model.objects.create() calls. This change: - Uses the proper factory method from sentry.testutils.fixtures.Fixtures - Maintains identical test behavior and coverage - Follows Sentry's testing best practices - Ensures proper test setup logic is applied Files changed: - tests/sentry/workflow_engine/endpoints/test_organization_open_periods.py Testing: - All existing tests pass with no modifications to test logic - No linter errors introduced --- .../endpoints/test_organization_open_periods.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/sentry/workflow_engine/endpoints/test_organization_open_periods.py b/tests/sentry/workflow_engine/endpoints/test_organization_open_periods.py index 5f270f8c2952c4..5d0aa2e8230ed5 100644 --- a/tests/sentry/workflow_engine/endpoints/test_organization_open_periods.py +++ b/tests/sentry/workflow_engine/endpoints/test_organization_open_periods.py @@ -16,7 +16,6 @@ from sentry.testutils.cases import APITestCase from sentry.types.activity import ActivityType from sentry.types.group import PriorityLevel -from sentry.workflow_engine.models.detector_group import DetectorGroup class OrganizationOpenPeriodsTest(APITestCase): @@ -35,7 +34,7 @@ def setUp(self) -> None: self.group.save() # Link detector to group - DetectorGroup.objects.create(detector=self.detector, group=self.group) + self.create_detector_group(detector=self.detector, group=self.group) self.group_open_period = GroupOpenPeriod.objects.get(group=self.group)