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-05-03 | MAIN --> PROD | DEV (967ddfa) --> STAGING #3795

Merged
merged 2 commits into from
May 3, 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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def check_for_gsa_migration_keyword(ir):
"passthrough_identifying_number",
"contains_chart_or_table",
"is_minimis_rate_used",
"compliance_requirement",
]

for range_name in range_names:
Expand Down
23 changes: 23 additions & 0 deletions backend/census_historical_migration/test_federal_awards_xforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
xform_program_name,
xform_is_passthrough_award,
is_valid_extension,
xform_cluster_names,
)


Expand Down Expand Up @@ -608,3 +609,25 @@ def test_with_missing_program_name(self):
xform_program_name(audits)

self.assertEqual(audits[0].FEDERALPROGRAMNAME, settings.GSA_MIGRATION)


class TestXformClusterNames(SimpleTestCase):
class MockAudit:
def __init__(self, cluster_name):
self.CLUSTERNAME = cluster_name

def test_cluster_name_not_other_cluster(self):
audits = []
audits.append(self.MockAudit("STUDENT FINANCIAL ASSISTANCE"))
audits.append(self.MockAudit("RESEARCH AND DEVELOPMENT"))
result = xform_cluster_names(audits)
for index in range(len(result)):
self.assertEqual(result[index].CLUSTERNAME, audits[index].CLUSTERNAME)

def test_cluster_name_other_cluster(self):
audits = []
audits.append(self.MockAudit("OTHER CLUSTER"))
audits.append(self.MockAudit("OTHER CLUSTER"))
result = xform_cluster_names(audits)
for audit in result:
self.assertEqual(audit.CLUSTERNAME, settings.OTHER_CLUSTER)
25 changes: 24 additions & 1 deletion backend/census_historical_migration/test_findings_xforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

from .workbooklib.findings_text import xform_add_placeholder_for_missing_references

from .workbooklib.findings import xform_sort_compliance_requirement
from .workbooklib.findings import (
xform_sort_compliance_requirement,
xform_missing_compliance_requirement,
)


class TestXformSortComplianceRequirement(SimpleTestCase):
Expand Down Expand Up @@ -97,3 +100,23 @@ def test_no_placeholder_addition_when_all_references_present(self):
) # Expecting two items in findings_texts
self.assertEqual(findings_texts[0].FINDINGREFNUMS, "ref1")
self.assertEqual(findings_texts[1].FINDINGREFNUMS, "ref2")


class TestXformMissingComplianceRequirement(SimpleTestCase):
class Findings:
def __init__(self, type_requirement):
self.TYPEREQUIREMENT = type_requirement

def test_missing_compliance_requirement(self):
mock_findings = [self.Findings("")]

xform_missing_compliance_requirement(mock_findings)

self.assertEqual(mock_findings[0].TYPEREQUIREMENT, settings.GSA_MIGRATION)

def test_normal_compliance_requirement(self):
mock_findings = [self.Findings("ABC")]

xform_missing_compliance_requirement(mock_findings)

self.assertEqual(mock_findings[0].TYPEREQUIREMENT, "ABC")
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,32 @@ def xform_populate_default_passthrough_amount(audits):
return passthrough_amounts


def xform_cluster_names(audits):
"""
If 'OTHER CLUSTER' is present in the clustername,
replace audit.CLUSTERNAME with settings.OTHER_CLUSTER and track transformation.
"""
change_records = []
is_other_cluster_found = False
for audit in audits:
cluster_name = string_to_string(audit.CLUSTERNAME)
if cluster_name and cluster_name.upper() == "OTHER CLUSTER":
is_other_cluster_found = True
track_transformations(
"CLUSTERNAME",
audit.CLUSTERNAME,
"cluster_name",
settings.OTHER_CLUSTER,
["xform_cluster_names"],
change_records,
)
audit.CLUSTERNAME = settings.OTHER_CLUSTER

if change_records and is_other_cluster_found:
InspectionRecord.append_federal_awards_changes(change_records)
return audits


def generate_federal_awards(audit_header, outfile):
"""
Generates a federal awards workbook for all awards associated with a given audit header.
Expand All @@ -546,6 +572,7 @@ def generate_federal_awards(audit_header, outfile):
uei = xform_retrieve_uei(audit_header.UEI)
set_workbook_uei(wb, uei)
audits = get_audits(audit_header.DBKEY, audit_header.AUDITYEAR)
audits = xform_cluster_names(audits)

(
cluster_names,
Expand Down Expand Up @@ -597,7 +624,7 @@ def generate_federal_awards(audit_header, outfile):
set_range(
wb,
"award_reference",
[f"AWARD-{n+1:04}" for n in range(len(audits))],
[f"AWARD-{n + 1:04}" for n in range(len(audits))],
)

# passthrough amount
Expand Down
26 changes: 26 additions & 0 deletions backend/census_historical_migration/workbooklib/findings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from audit.fixtures.excel import FORM_SECTIONS
from ..models import ELECAUDITFINDINGS as Findings
import openpyxl as pyxl
from django.conf import settings

import logging

Expand All @@ -32,6 +33,30 @@ def xform_sort_compliance_requirement(findings):
finding.TYPEREQUIREMENT = "".join(sorted(value))


def xform_missing_compliance_requirement(findings):
"""Defaults missing compliance_requirement to GSA_MIGRATION."""
change_records = []
is_empty_compliance_requirement_found = False

for finding in findings:
compliance_requirement = string_to_string(finding.TYPEREQUIREMENT)
if not compliance_requirement:
track_transformations(
"TYPEREQUIREMENT",
finding.TYPEREQUIREMENT,
"type_requirement",
settings.GSA_MIGRATION,
["xform_missing_compliance_requirement"],
change_records,
)

is_empty_compliance_requirement_found = True
finding.TYPEREQUIREMENT = settings.GSA_MIGRATION

if change_records and is_empty_compliance_requirement_found:
InspectionRecord.append_finding_changes(change_records)


def xform_prior_year_findings(value):
"""
Transform the value of prior_references to N/A if empty.
Expand Down Expand Up @@ -172,6 +197,7 @@ def generate_findings(audit_header, outfile):
findings = get_findings(audit_header.DBKEY, audit_header.AUDITYEAR)
award_references = xform_construct_award_references(audits, findings)
xform_sort_compliance_requirement(findings)
xform_missing_compliance_requirement(findings)
map_simple_columns(wb, mappings, findings)
set_range(wb, "award_reference", award_references)

Expand Down
Loading
Loading