Skip to content

Commit 1cd73eb

Browse files
fix: include approved sets in findings (#310)
1 parent 72db025 commit 1cd73eb

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

src/hope_dedup_engine/apps/api/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def get_queryset(self) -> QuerySet[Finding]:
369369
deduplication_set__pk=self.kwargs["deduplication_set_pk"],
370370
deduplication_set__group__system=self.request.auth.system,
371371
deduplication_set__group__deleted=False,
372-
deduplication_set__state=DeduplicationSet.State.DEDUPLICATED,
372+
deduplication_set__state__in=[DeduplicationSet.State.DEDUPLICATED, DeduplicationSet.State.APPROVED],
373373
)
374374
.select_related("first_encoding", "second_encoding")
375375
.order_by("-updated_at", "-id")

tests/api/test_duplicate_list.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@
1515

1616

1717
@pytest.fixture
18-
def deduplicated_set(deduplication_set: DeduplicationSet) -> DeduplicationSet:
19-
deduplication_set.state = DeduplicationSet.State.DEDUPLICATED
18+
def deduplicated_set(
19+
request: pytest.FixtureRequest,
20+
deduplication_set: DeduplicationSet,
21+
) -> DeduplicationSet:
22+
deduplication_set.state = getattr(
23+
request,
24+
"param",
25+
DeduplicationSet.State.DEDUPLICATED,
26+
)
2027
deduplication_set.save(update_fields=["state"])
2128
return deduplication_set
2229

@@ -25,6 +32,14 @@ def findings_url(deduplication_set_pk: str) -> str:
2532
return reverse(FINDINGS_VIEW, kwargs={"deduplication_set_pk": deduplication_set_pk})
2633

2734

35+
@pytest.mark.parametrize(
36+
"deduplicated_set",
37+
[
38+
DeduplicationSet.State.DEDUPLICATED,
39+
DeduplicationSet.State.APPROVED,
40+
],
41+
indirect=True,
42+
)
2843
def test_can_list_duplicates(api_client: APIClient, deduplicated_set: DeduplicationSet, finding: Finding) -> None:
2944
response = api_client.get(findings_url(deduplicated_set.pk))
3045
assert response.status_code == status.HTTP_200_OK
@@ -33,7 +48,7 @@ def test_can_list_duplicates(api_client: APIClient, deduplicated_set: Deduplicat
3348
assert "config" in data["results"][0]
3449

3550

36-
def test_findings_only_visible_when_deduplicated(
51+
def test_findings_only_visible_when_deduplicated_or_approved(
3752
api_client: APIClient, deduplication_set: DeduplicationSet, finding: Finding
3853
) -> None:
3954
response = api_client.get(findings_url(deduplication_set.pk))

0 commit comments

Comments
 (0)