Skip to content

Commit

Permalink
#3202 Updated code to migrate cognizant and oversight data (#3204)
Browse files Browse the repository at this point in the history
* #3202 Updated code to migrate cognizant and oversight data

* #3202 Fixed failing tests
  • Loading branch information
sambodeme authored Jan 16, 2024
1 parent c6b4fe1 commit be95d5a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from ..exception_utils import DataMigrationError
from ..transforms.xform_string_to_string import string_to_string


def cognizant_oversight(audit_header):
"""Retrieve cognizant oversight information for a given audit header."""

cognizant = string_to_string(audit_header.COGAGENCY)
oversight = string_to_string(audit_header.OVERSIGHTAGENCY)
if cognizant and len(cognizant) > 2:
raise DataMigrationError(
f"Invalid cognizant agency: {cognizant}", "invalid_cognizant"
)

return cognizant, oversight
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from django.apps import apps
from django.conf import settings

from .cognizant_oversight import cognizant_oversight

from ..exception_utils import DataMigrationError
from .general_information import (
general_information,
Expand Down Expand Up @@ -80,6 +82,9 @@ def setup_sac(user, audit_header):

sac.auditee_certification = auditee_certification(audit_header)
sac.auditor_certification = auditor_certification(audit_header)
cognizant, oversight = cognizant_oversight(audit_header)
sac.cognizant_agency = cognizant
sac.oversight_agency = oversight
sac.data_source = settings.CENSUS_DATA_SOURCE

if general_info["user_provided_organization_type"] == "tribal":
Expand Down
2 changes: 2 additions & 0 deletions backend/census_historical_migration/test_sac_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def __init__(
self.TYPEREPORT_SP_FRAMEWORK = "UQAD"
self.UEI = "ZQGGHJH74DW7"
self.ZIPCODE = "10451"
self.COGAGENCY = "14"
self.OVERSIGHTAGENCY = "84"

def _mock_audit_header(self, entity_type, suppression_code=None):
"""Returns a mock audit header with all necessary fields"""
Expand Down

0 comments on commit be95d5a

Please sign in to comment.