Skip to content

Commit

Permalink
Merge pull request #1974 from GSA-TTS/main
Browse files Browse the repository at this point in the history
  • Loading branch information
jadudm authored Aug 30, 2023
2 parents 047d55f + 319aba5 commit 6831f6a
Show file tree
Hide file tree
Showing 38 changed files with 1,048 additions and 1,031 deletions.
265 changes: 119 additions & 146 deletions backend/audit/etl.py

Large diffs are not rendered by default.

This file was deleted.

12 changes: 0 additions & 12 deletions backend/audit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,6 @@ class STATUS:
max_length=20, choices=AUDIT_TYPE_CODES, blank=True, null=True
)

# Computed fields
cognizant_agency = models.CharField(
max_length=2,
blank=True,
null=True,
)
oversight_agency = models.CharField(
max_length=2,
blank=True,
null=True,
)

# General Information
# The general information fields are currently specified in two places:
# - report_submission.forms.GeneralInformationForm
Expand Down
File renamed without changes.
37 changes: 8 additions & 29 deletions backend/audit/test_etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from model_bakery import baker
from faker import Faker


from .models import SingleAuditChecklist, User
from dissemination.models import (
General,
Expand All @@ -14,8 +13,6 @@
FindingText,
CapText,
SecondaryAuditor,
AdditionalUei,
AdditionalEin,
)
from audit.etl import ETL

Expand All @@ -37,6 +34,7 @@ def setUp(self):
corrective_action_plan=self._fake_corrective_action_plan(),
secondary_auditors=self._fake_secondary_auditors(),
additional_ueis=self._fake_additional_ueis(),
# audit_information=self._fake_audit_information(), # TODO: Uncomment when SingleAuditChecklist adds audit_information
)
sac.save()
self.sac = sac
Expand Down Expand Up @@ -263,18 +261,6 @@ def _fake_additional_ueis():
}
}

@staticmethod
def _fake_additional_eins():
return {
"AdditionalEINs": {
"auditee_uei": "ZQGGHJH74DW7",
"additional_eins_entries": [
{"additional_ein": "874151234"},
{"additional_ein": "876505678"},
],
}
}

def test_load_general(self):
self.etl.load_general()
generals = General.objects.all()
Expand Down Expand Up @@ -338,13 +324,9 @@ def test_load_captext(self):
def test_load_sec_auditor(self):
self.etl.load_secondary_auditor()
sec_auditor = SecondaryAuditor.objects.first()
self.assertIsNone(sec_auditor)
self.etl.load_general()
self.etl.load_secondary_auditor()
sec_auditor = SecondaryAuditor.objects.first()

self.assertEquals(self.sac.report_id, sec_auditor.report_id)

# TODO rename to test_load_audit once frontend is available
def todo_load_audit_information(self):
self.etl.load_audit_info()
general = General.objects.first()
Expand All @@ -356,8 +338,6 @@ def test_load_all(self):
tables."""
len_general = len(General.objects.all())
len_captext = len(CapText.objects.all())
len_additional_ueis = len(AdditionalUei.objects.all())
len_additional_eins = len(AdditionalEin.objects.all())
sac = SingleAuditChecklist.objects.create(
submitted_by=self.user,
general_information=self._fake_general(),
Expand All @@ -368,8 +348,7 @@ def test_load_all(self):
corrective_action_plan=self._fake_corrective_action_plan(),
secondary_auditors=self._fake_secondary_auditors(),
additional_ueis=self._fake_additional_ueis(),
additional_eins=self._fake_additional_eins(),
audit_information=self._fake_audit_information(), # TODO: Uncomment when SingleAuditChecklist adds audit_information
# audit_information=self._fake_audit_information(), # TODO: Uncomment when SingleAuditChecklist adds audit_information
)
sac.save()
self.sac = sac
Expand All @@ -378,12 +357,10 @@ def test_load_all(self):
self.etl.load_all()
self.assertLess(len_general, len(General.objects.all()))
self.assertLess(len_captext, len(CapText.objects.all()))
self.assertLess(len_additional_ueis, len(AdditionalUei.objects.all()))
self.assertLess(len_additional_eins, len(AdditionalEin.objects.all()))

def test_load_all_with_errors_1(self):
"""We should not encounter a key error in general,
an error that would prevent the loading of a child table
"""If we encounter a KeyError on General (the first table to be loaded), we
should still load all the other tables, but nothing should be loaded to General.
"""
len_general = len(General.objects.all())
len_captext = len(CapText.objects.all())
Expand All @@ -397,14 +374,15 @@ def test_load_all_with_errors_1(self):
corrective_action_plan=self._fake_corrective_action_plan(),
secondary_auditors=self._fake_secondary_auditors(),
additional_ueis=self._fake_additional_ueis(),
# audit_information=self._fake_audit_information(), # TODO: Uncomment when SingleAuditChecklist adds audit_information
)
sac.general_information.pop("auditee_contact_name")
sac.save()
self.sac = sac
self.etl = ETL(self.sac)
self.report_id = sac.report_id
self.etl.load_all()
self.assertLess(len_general, len(General.objects.all()))
self.assertEqual(len_general, len(General.objects.all()))
self.assertLess(len_captext, len(CapText.objects.all()))

def test_load_all_with_errors_2(self):
Expand All @@ -423,6 +401,7 @@ def test_load_all_with_errors_2(self):
corrective_action_plan=self._fake_corrective_action_plan(),
secondary_auditors=self._fake_secondary_auditors(),
additional_ueis=self._fake_additional_ueis(),
# audit_information=self._fake_audit_information(), # TODO: Uncomment when SingleAuditChecklist adds audit_information
)
sac.corrective_action_plan.pop("CorrectiveActionPlan")
sac.save()
Expand Down
Loading

0 comments on commit 6831f6a

Please sign in to comment.