-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3083 from GSA-TTS/main
- Loading branch information
Showing
7 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
Binary file added
BIN
+222 KB
...ixtures/workbooks/should_fail/federal-awards-audit-findings/has_bad_award_references.xlsx
Binary file not shown.
Binary file added
BIN
+222 KB
.../audit/fixtures/workbooks/should_pass/award_references/has-lowercase-award-reference.xlsx
Binary file not shown.
38 changes: 38 additions & 0 deletions
38
backend/audit/intakelib/checks/check_finding_award_references_pattern.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import logging | ||
from django.core.exceptions import ValidationError | ||
import re | ||
from audit.intakelib.intermediate_representation import ( | ||
get_range_by_name, | ||
) | ||
from audit.intakelib.common import ( | ||
get_message, | ||
build_cell_error_tuple, | ||
) | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
# A version of these regexes also exists in Base.libsonnet | ||
AWARD_REFERENCES_REGEX = r"^AWARD-(?!0000)[0-9]{4}$" | ||
|
||
|
||
# DESCRIPTION | ||
# Award references should be of format AWARD-#### | ||
# TESTED BY | ||
# has_bad_award_references.xlsx | ||
def award_references_pattern(ir): | ||
award_references = get_range_by_name(ir, "award_reference") | ||
errors = [] | ||
for index, award_reference in enumerate(award_references["values"]): | ||
if not re.match(AWARD_REFERENCES_REGEX, str(award_reference)): | ||
errors.append( | ||
build_cell_error_tuple( | ||
ir, | ||
award_references, | ||
index, | ||
get_message("check_award_references_invalid"), | ||
) | ||
) | ||
|
||
if len(errors) > 0: | ||
logger.info("Raising a validation error.") | ||
raise ValidationError(errors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
backend/audit/intakelib/transforms/xform_reformat_award_references.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import logging | ||
from audit.intakelib.intermediate_representation import ( | ||
get_range_by_name, | ||
replace_range_by_name, | ||
) | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
# Tested by has_lowercase_award_reference.py | ||
def reformat_award_reference(ir): | ||
references = get_range_by_name(ir, "award_reference") | ||
new_values = list(map(lambda v: v.upper() if v else v, references["values"])) | ||
new_ir = replace_range_by_name(ir, "award_reference", new_values) | ||
return new_ir |