Skip to content

Commit 0198418

Browse files
Switch to DojoTestCase for better test compatibility
Use DojoTestCase instead of plain TestCase to align with DefectDojo testing conventions and ensure proper test setup/teardown.
1 parent 5e4110b commit 0198418

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

dojo/filters.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,14 +2020,15 @@ def get_finding_group_queryset_for_context(pid=None, eid=None, tid=None):
20202020
"""
20212021
Helper function to build finding group queryset based on context hierarchy.
20222022
Context priority: test > engagement > product > global
2023-
2023+
20242024
Args:
20252025
pid: Product ID (least specific)
20262026
eid: Engagement ID
20272027
tid: Test ID (most specific)
2028-
2028+
20292029
Returns:
20302030
QuerySet of Finding_Group filtered by context
2031+
20312032
"""
20322033
if tid is not None:
20332034
# Most specific: filter by test
@@ -2234,7 +2235,7 @@ def set_related_object_fields(self, *args: list, **kwargs: dict):
22342235
eid=self.eid,
22352236
tid=self.tid,
22362237
)
2237-
2238+
22382239
# Filter by most specific context: test > engagement > product
22392240
if self.tid is not None:
22402241
# Test context: filter finding groups by test

unittests/test_finding_group_filter_context.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from django.test import TestCase
21
from django.utils.timezone import now
32

43
from dojo.filters import FindingFilter, FindingFilterWithoutObjectLookups
@@ -13,16 +12,19 @@
1312
Test_Type,
1413
)
1514

15+
from .dojo_test_case import DojoTestCase
16+
17+
18+
class TestFindingGroupFilterContext(DojoTestCase):
1619

17-
class TestFindingGroupFilterContext(TestCase):
1820
"""Test that Finding Group filter respects Test/Engagement/Product context."""
1921

2022
@classmethod
2123
def setUpTestData(cls):
2224
"""Create test data hierarchy."""
2325
# Create test type
2426
cls.test_type = Test_Type.objects.create(name="Test Type")
25-
27+
2628
# Create user
2729
cls.user = Dojo_User.objects.create(
2830
username="testuser",

0 commit comments

Comments
 (0)