Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024-11-28 | MAIN --> PROD | DEV (ed76205) --> STAGING #4492

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions backend/dissemination/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,56 @@ def test_summary_context(self):
note.accounting_policies,
)

def test_distinct_findings_by_reference_number(self):
"""
Test that the Audit Findings in the context only include distinct findings
based on the `reference_number` for a given report_id.
"""
gen = baker.make(General, report_id="2022-12-GSAFAC-0000000001", is_public=True)

# Create multiple findings with the same reference_number
baker.make(Finding, report_id=gen, reference_number="REF001")
baker.make(Finding, report_id=gen, reference_number="REF001")
baker.make(Finding, report_id=gen, reference_number="REF002")

url = reverse(
"dissemination:Summary", kwargs={"report_id": "2022-12-GSAFAC-0000000001"}
)

response = self.client.get(url)

# Verify that the response contains only distinct reference_numbers
findings = response.context["data"]["Audit Findings"]
reference_numbers = [finding["reference_number"] for finding in findings]
self.assertEqual(len(reference_numbers), len(set(reference_numbers)))
self.assertIn("REF001", reference_numbers)
self.assertIn("REF002", reference_numbers)
self.assertEqual(len(reference_numbers), 2) # Only 2 distinct reference numbers

def test_unique_findings_no_duplicates(self):
"""
Test that the Audit Findings in the context include all findings
when all `reference_number` values are unique for a given report_id.
"""
gen = baker.make(General, report_id="2022-12-GSAFAC-0000000002", is_public=True)

# findings with unique reference_numbers
baker.make(Finding, report_id=gen, reference_number="REF003")
baker.make(Finding, report_id=gen, reference_number="REF004")

url = reverse(
"dissemination:Summary", kwargs={"report_id": "2022-12-GSAFAC-0000000002"}
)

response = self.client.get(url)

# Verify that all unique reference_numbers are present
findings = response.context["data"]["Audit Findings"]
reference_numbers = [finding["reference_number"] for finding in findings]
self.assertEqual(len(reference_numbers), 2) # all findings are returned
self.assertIn("REF003", reference_numbers)
self.assertIn("REF004", reference_numbers)

def test_sac_download_available(self):
"""
Ensures is_sf_sac_downloadable is True when a submission's SF-SAC is downloadable
Expand Down
6 changes: 5 additions & 1 deletion backend/dissemination/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,11 @@ def get_audit_content(self, report_id, include_private_and_public):
Wrap that data into a dict, and return it.
"""
awards = FederalAward.objects.filter(report_id=report_id)
audit_findings = Finding.objects.filter(report_id=report_id)
audit_findings = (
Finding.objects.filter(report_id=report_id)
.order_by("reference_number")
.distinct("reference_number")
)
audit_findings_text = FindingText.objects.filter(report_id=report_id)
corrective_action_plan = CapText.objects.filter(report_id=report_id)
notes_to_sefa = Note.objects.filter(report_id=report_id)
Expand Down