Skip to content

Commit

Permalink
Supporting validation waiver
Browse files Browse the repository at this point in the history
  • Loading branch information
phildominguez-gsa committed Nov 15, 2024
1 parent 491cfc9 commit b95f789
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def check_finding_prior_references(sac_dict, *_args, **_kwargs):
Check that prior references numbers point to findings that actually exist
in a previously submitted report
"""
# Importing here to avoid circular import
from audit.models import SacValidationWaiver

if SacValidationWaiver.TYPES.PRIOR_REFERENCES in sac_dict.get("waiver_types", []):
return []

all_sections = sac_dict.get("sf_sac_sections")
findings_uniform_guidance_section = (
all_sections.get("findings_uniform_guidance") or {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
_get_prior_refs,
)
from .sac_validation_shape import sac_validation_shape
from audit.models import SingleAuditChecklist
from audit.models import SingleAuditChecklist, SacValidationWaiver
from dissemination.models import (
Finding,
General,
Expand All @@ -20,9 +20,10 @@ def _test_check_finding_prior_references(
self,
auditee_fiscal_period_start, # ISO date string
awards_prior_refs, # Dict of award # -> prior reference string
repeat_prior_reference, # Set 'Y' or 'N' in findings_uniform_guidance_entries
repeat_prior_reference, # Bool to set 'Y' or 'N' in findings_uniform_guidance_entries
prior_report_exists, # Bool for if prior report should exist in General
gen_reports_from_prior_ref_years, # Bool for generating reports from prior reference years instead of the previous year
use_waiver, # Bool for using a validation waiver
expected_error_strs, # List of error strings
):
"""
Expand Down Expand Up @@ -57,6 +58,15 @@ def _test_check_finding_prior_references(
}
},
)

if use_waiver:
baker.make(
SacValidationWaiver,
report_id=new_sac,
waiver_types=[SacValidationWaiver.TYPES.PRIOR_REFERENCES],
)
new_sac.waiver_types = [SacValidationWaiver.TYPES.PRIOR_REFERENCES]

new_sac.save()

if prior_report_exists:
Expand Down Expand Up @@ -118,6 +128,7 @@ def test_check_finding_prior_references_single_prior(self):
repeat_prior_reference="Y",
prior_report_exists=True,
gen_reports_from_prior_ref_years=False,
use_waiver=False,
expected_error_strs=[],
)

Expand All @@ -134,6 +145,7 @@ def test_check_finding_prior_references_use_prior_ref_years(self):
repeat_prior_reference="Y",
prior_report_exists=True,
gen_reports_from_prior_ref_years=True,
use_waiver=False,
expected_error_strs=[],
)

Expand All @@ -150,6 +162,7 @@ def test_check_finding_prior_references_before_2022(self):
repeat_prior_reference="Y",
prior_report_exists=False,
gen_reports_from_prior_ref_years=False,
use_waiver=False,
expected_error_strs=[],
)

Expand All @@ -165,6 +178,7 @@ def test_check_finding_prior_references_multiple_priors(self):
repeat_prior_reference="Y",
prior_report_exists=True,
gen_reports_from_prior_ref_years=False,
use_waiver=False,
expected_error_strs=[],
)

Expand All @@ -181,6 +195,7 @@ def test_check_finding_prior_references_multiple_awards(self):
repeat_prior_reference="Y",
prior_report_exists=True,
gen_reports_from_prior_ref_years=False,
use_waiver=False,
expected_error_strs=[],
)

Expand All @@ -197,6 +212,7 @@ def test_check_finding_prior_references_n_a_with_y(self):
repeat_prior_reference="Y",
prior_report_exists=True,
gen_reports_from_prior_ref_years=False,
use_waiver=False,
expected_error_strs=[
{
"error": "AWARD-001 field repeat_prior_reference is set to 'Y', but prior_references is set to 'N/A'.",
Expand All @@ -216,13 +232,30 @@ def test_check_finding_prior_references_no_prior_report(self):
repeat_prior_reference="Y",
prior_report_exists=False,
gen_reports_from_prior_ref_years=False,
use_waiver=False,
expected_error_strs=[
{
"error": "Findings uniform guidance contains prior reference numbers, but no related report was found for UEI ABC123DEF456.",
}
],
)

def test_check_finding_prior_references_waiver(self):
"""
Invalid prior references should still pass when a waiver is present
"""
self._test_check_finding_prior_references(
auditee_fiscal_period_start="2024-01-01",
awards_prior_refs={
"AWARD-001": "N/A",
},
repeat_prior_reference="Y",
prior_report_exists=False,
gen_reports_from_prior_ref_years=False,
use_waiver=True,
expected_error_strs=[],
)

def test_get_prior_refs(self):
"""
Extracting prior_references from an award should pass
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 5.1.2 on 2024-11-15 14:39

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("audit", "0001_squashed_0013_singleauditchecklistflow_and_more"),
]

operations = [
migrations.AlterField(
model_name="sacvalidationwaiver",
name="waiver_types",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(
choices=[
(
"auditee_certifying_official",
"No auditee certifying official is available",
),
(
"auditor_certifying_official",
"No auditor certifying official is available",
),
(
"finding_reference_number",
"Report has duplicate finding reference numbers",
),
(
"prior_references",
"Report has invalid prior reference numbers",
),
],
max_length=50,
),
default=list,
size=None,
verbose_name="The waiver type",
),
),
]
5 changes: 5 additions & 0 deletions backend/audit/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ class TYPES:
AUDITEE_CERTIFYING_OFFICIAL = "auditee_certifying_official"
AUDITOR_CERTIFYING_OFFICIAL = "auditor_certifying_official"
FINDING_REFERENCE_NUMBER = "finding_reference_number"
PRIOR_REFERENCES = "prior_references"

WAIVER_CHOICES = [
(
Expand All @@ -672,6 +673,10 @@ class TYPES:
TYPES.FINDING_REFERENCE_NUMBER,
"Report has duplicate finding reference numbers",
),
(
TYPES.PRIOR_REFERENCES,
"Report has invalid prior reference numbers",
),
]
report_id = models.ForeignKey(
"SingleAuditChecklist",
Expand Down

0 comments on commit b95f789

Please sign in to comment.