-
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 #3088 from GSA-TTS/main
- Loading branch information
Showing
11 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
Binary file added
BIN
+770 KB
backend/audit/fixtures/workbooks/should_fail/federal-awards/has-bad-aln-prefixes.xlsx
Binary file not shown.
Binary file added
BIN
+771 KB
...ks/should_pass/aln_read_as_decimal_values/has-aln-prefix-returned-as-decimal-numbers.xlsx
Binary file not shown.
33 changes: 33 additions & 0 deletions
33
backend/audit/intakelib/checks/check_aln_prefix_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,33 @@ | ||
import logging | ||
import re | ||
from django.conf import settings | ||
|
||
from django.core.exceptions import ValidationError | ||
from ..intermediate_representation import ( | ||
get_range_by_name, | ||
) | ||
from ..common import get_message, build_cell_error_tuple | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
# DESCRIPTION | ||
# The ALN prefix represents a two-digit number ## | ||
# TESTED BY has_bad_aln_prefix.xlsx | ||
def aln_agency_prefix(ir): | ||
prefixes = get_range_by_name(ir, "federal_agency_prefix") | ||
errors = [] | ||
for index, prefix in enumerate(prefixes["values"]): | ||
if not re.match(settings.REGEX_ALN_PREFIX, str(prefix)): | ||
errors.append( | ||
build_cell_error_tuple( | ||
ir, | ||
prefixes, | ||
index, | ||
get_message("check_aln_prefix_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
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_agency_prefix.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-aln-prefix-entered-as-numbers.xlsx | ||
def reformat_federal_agency_prefix(ir): | ||
references = get_range_by_name(ir, "federal_agency_prefix") | ||
new_values = list(map(lambda v: v.split(".")[0] if v else v, references["values"])) | ||
new_ir = replace_range_by_name(ir, "federal_agency_prefix", new_values) | ||
return new_ir |
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