Skip to content

Commit

Permalink
Sk/3955 blank finding refnums (#3964)
Browse files Browse the repository at this point in the history
* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Handling blank finding reference number

* Update backend/audit/intakelib/checks/check_finding_reference_pattern.py

Co-authored-by: Hassan D. M. Sambo <[email protected]>

---------

Co-authored-by: Hassan D. M. Sambo <[email protected]>
  • Loading branch information
gsa-suk and sambodeme authored Jun 11, 2024
1 parent 24a05e0 commit f2aa937
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
build_cell_error_tuple,
appears_empty,
)
from django.conf import settings

logger = logging.getLogger(__name__)

Expand All @@ -21,12 +22,14 @@
# digits are a year >= 1900.
# TESTED BY
# has_bad_references.xlsx
def finding_reference_pattern(ir):
def finding_reference_pattern(ir, is_gsa_migration=False):
references = get_range_by_name(ir, "reference_number")
errors = []
for index, reference in enumerate(references["values"]):
if not appears_empty(reference) and (
not re.match(FINDING_REFERENCE_REGEX, str(reference))
if (
not appears_empty(reference)
and (reference == settings.GSA_MIGRATION and not is_gsa_migration)
and (not re.match(FINDING_REFERENCE_REGEX, str(reference)))
):
errors.append(
build_cell_error_tuple(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def check_for_gsa_migration_keyword(ir):
"material_weakness",
"significant_deficiency",
"repeat_prior_reference",
"reference_number",
"is_guaranteed",
]

Expand Down
2 changes: 1 addition & 1 deletion backend/audit/intakelib/checks/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"federal_program_total_is_correct": federal_program_total_is_correct,
}

require_gsa_migration_flag = [findings_grid_validation]
require_gsa_migration_flag = [findings_grid_validation, finding_reference_pattern]


def run_all_checks(
Expand Down
8 changes: 8 additions & 0 deletions backend/census_historical_migration/test_findings_xforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,15 @@ def __init__(
SIGNIFICANTDEFICIENCY,
OTHERFINDINGS,
QCOSTS,
FINDINGREFNUMS,
):
self.MODIFIEDOPINION = MODIFIEDOPINION
self.OTHERNONCOMPLIANCE = OTHERNONCOMPLIANCE
self.MATERIALWEAKNESS = MATERIALWEAKNESS
self.SIGNIFICANTDEFICIENCY = SIGNIFICANTDEFICIENCY
self.OTHERFINDINGS = OTHERFINDINGS
self.QCOSTS = QCOSTS
self.FINDINGREFNUMS = FINDINGREFNUMS

def test_replace_empty_fields(self):
findings = [
Expand All @@ -283,6 +285,7 @@ def test_replace_empty_fields(self):
SIGNIFICANTDEFICIENCY="",
OTHERFINDINGS="Present",
QCOSTS="",
FINDINGREFNUMS="",
),
self.Finding(
MODIFIEDOPINION="Present",
Expand All @@ -291,6 +294,7 @@ def test_replace_empty_fields(self):
SIGNIFICANTDEFICIENCY="",
OTHERFINDINGS="Present",
QCOSTS="",
FINDINGREFNUMS="Present",
),
self.Finding(
MODIFIEDOPINION="",
Expand All @@ -299,6 +303,7 @@ def test_replace_empty_fields(self):
SIGNIFICANTDEFICIENCY="",
OTHERFINDINGS="",
QCOSTS="Present",
FINDINGREFNUMS="",
),
]

Expand All @@ -310,20 +315,23 @@ def test_replace_empty_fields(self):
self.assertEqual(findings[0].SIGNIFICANTDEFICIENCY, settings.GSA_MIGRATION)
self.assertEqual(findings[0].OTHERFINDINGS, "Present")
self.assertEqual(findings[0].QCOSTS, settings.GSA_MIGRATION)
self.assertEqual(findings[0].FINDINGREFNUMS, settings.GSA_MIGRATION)

self.assertEqual(findings[1].MODIFIEDOPINION, "Present")
self.assertEqual(findings[1].OTHERNONCOMPLIANCE, "Present")
self.assertEqual(findings[1].MATERIALWEAKNESS, settings.GSA_MIGRATION)
self.assertEqual(findings[1].SIGNIFICANTDEFICIENCY, settings.GSA_MIGRATION)
self.assertEqual(findings[1].OTHERFINDINGS, "Present")
self.assertEqual(findings[1].QCOSTS, settings.GSA_MIGRATION)
self.assertEqual(findings[1].FINDINGREFNUMS, "Present")

self.assertEqual(findings[2].MODIFIEDOPINION, settings.GSA_MIGRATION)
self.assertEqual(findings[2].OTHERNONCOMPLIANCE, "Present")
self.assertEqual(findings[2].MATERIALWEAKNESS, "Present")
self.assertEqual(findings[2].SIGNIFICANTDEFICIENCY, settings.GSA_MIGRATION)
self.assertEqual(findings[2].OTHERFINDINGS, settings.GSA_MIGRATION)
self.assertEqual(findings[2].QCOSTS, "Present")
self.assertEqual(findings[2].FINDINGREFNUMS, settings.GSA_MIGRATION)


class TestXformMissingRepeatPriorReference(SimpleTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def xform_add_placeholder_for_missing_references(findings, captexts):
missing_references = expected_references - found_references
if missing_references:
for ref in missing_references:
if not ref:
ref = settings.GSA_MIGRATION
captexts.append(
CapText(
SEQ_NUMBER="0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def xform_replace_required_fields_with_gsa_migration_when_empty(findings):
("SIGNIFICANTDEFICIENCY", "is_significant_deficiency"),
("OTHERFINDINGS", "is_other_findings"),
("QCOSTS", "is_questioned_costs"),
("FINDINGREFNUMS", "reference_number"),
]

for in_db, in_dissem in fields_to_check:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def xform_add_placeholder_for_missing_references(findings, findings_texts):

if missing_references:
for ref in missing_references:
if not ref:
ref = settings.GSA_MIGRATION
findings_texts.append(
FindingsText(
SEQ_NUMBER="0",
Expand Down
16 changes: 12 additions & 4 deletions backend/schemas/output/sections/AuditFindingsText.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,18 @@
"type": "string"
},
"reference_number": {
"description": "Reference Number",
"pattern": "^[1-2][0-9]{3}-[0-9]{3}$",
"title": "ReferenceNumber",
"type": "string"
"oneOf": [
{
"description": "Reference Number",
"pattern": "^[1-2][0-9]{3}-[0-9]{3}$",
"title": "ReferenceNumber",
"type": "string"
},
{
"const": "GSA_MIGRATION",
"type": "string"
}
]
},
"text_of_finding": {
"type": "string"
Expand Down
16 changes: 12 additions & 4 deletions backend/schemas/output/sections/CorrectiveActionPlan.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,18 @@
"type": "string"
},
"reference_number": {
"description": "Reference Number",
"pattern": "^[1-2][0-9]{3}-[0-9]{3}$",
"title": "ReferenceNumber",
"type": "string"
"oneOf": [
{
"description": "Reference Number",
"pattern": "^[1-2][0-9]{3}-[0-9]{3}$",
"title": "ReferenceNumber",
"type": "string"
},
{
"const": "GSA_MIGRATION",
"type": "string"
}
]
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,18 @@
"type": "string"
},
"reference_number": {
"description": "Reference Number",
"pattern": "^[1-2][0-9]{3}-[0-9]{3}$",
"title": "ReferenceNumber",
"type": "string"
"oneOf": [
{
"description": "Reference Number",
"pattern": "^[1-2][0-9]{3}-[0-9]{3}$",
"title": "ReferenceNumber",
"type": "string"
},
{
"const": "GSA_MIGRATION",
"type": "string"
}
]
},
"repeat_prior_reference": {
"enum": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ local Meta = Types.object {
local FindingsTextEntry = {
additionalProperties: false,
properties: {
reference_number: Base.Compound.ReferenceNumber,
reference_number: {
oneOf: [
Base.Compound.ReferenceNumber,
Types.string {
const: Base.Const.GSA_MIGRATION,
},
],
},
text_of_finding: Types.string,
contains_chart_or_table: Base.Enum.YorNorGsaMigration,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ local Meta = Types.object {
local CorrectiveActionPlanEntry = {
additionalProperties: false,
properties: {
reference_number: Base.Compound.ReferenceNumber,
reference_number: {
oneOf: [
Base.Compound.ReferenceNumber,
Types.string {
const: Base.Const.GSA_MIGRATION,
},
],
},
planned_action: Types.string,
contains_chart_or_table: Base.Enum.YorNorGsaMigration,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ local Parts = {
Findings: Types.object {
additionalProperties: false,
properties: {
reference_number: Base.Compound.ReferenceNumber,
reference_number: {
oneOf: [
Base.Compound.ReferenceNumber,
Types.string {
const: Base.Const.GSA_MIGRATION,
},
],
},
is_valid: Base.Enum.YorNorGsaMigration,
repeat_prior_reference: Base.Enum.YorNorGsaMigration,
prior_references: Types.string,
Expand Down

0 comments on commit f2aa937

Please sign in to comment.