Skip to content

Commit

Permalink
- Re-added missing fields
Browse files Browse the repository at this point in the history
- Updating tests
  • Loading branch information
elipe17 committed Sep 25, 2023
1 parent 265d498 commit 78f108b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
38 changes: 37 additions & 1 deletion tdrs-backend/tdpservice/parsers/schema_defs/tanf/t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,43 @@
validators.or_validators(validators.isInStringRange(0, 99),
validators.isNone()),
]),

Field(item="7", name='ZIP_CODE', type='string', startIndex=24, endIndex=29,
required=True, validators=[
validators.isNumber(),
]),
Field(item="8", name='FUNDING_STREAM', type='number', startIndex=29, endIndex=30,
required=True, validators=[
validators.isInLimits(1, 3),
]),
Field(item="9", name='DISPOSITION', type='number', startIndex=30, endIndex=31,
required=True, validators=[
validators.oneOf([1, 2]),
]),
Field(item="10", name='NEW_APPLICANT', type='number', startIndex=31, endIndex=32,
required=True, validators=[
validators.oneOf([1, 2]),
]),
Field(item="11", name='NBR_FAMILY_MEMBERS', type='number', startIndex=32, endIndex=34,
required=True, validators=[
validators.isLargerThan(0),
]),
Field(item="12", name='FAMILY_TYPE', type='number', startIndex=34, endIndex=35,
required=True, validators=[
validators.isInLimits(1, 3),
]),
Field(item="13", name='RECEIVES_SUB_HOUSING', type='number', startIndex=35, endIndex=36,
required=True, validators=[
validators.isInLimits(1, 3),
]),
Field(item="14", name='RECEIVES_MED_ASSISTANCE', type='number', startIndex=36, endIndex=37,
required=True, validators=[
validators.isInLimits(1, 2)
]),
Field(item="15", name='RECEIVES_FOOD_STAMPS', type='number', startIndex=37, endIndex=38,
can_be_empty=True, required=True, validators=[
validators.or_validators(validators.isInLimits(0, 2),
validators.isNone()),
]),
Field(item="16", name='AMT_FOOD_STAMP_ASSISTANCE', type='number', startIndex=38, endIndex=42,
required=True, validators=[
validators.isLargerThanOrEqualTo(0),
Expand Down
17 changes: 9 additions & 8 deletions tdrs-backend/tdpservice/parsers/test/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ def test_parse_big_file(test_big_file):
parse.parse_datafile(test_big_file)
parser_errors = ParserError.objects.filter(file=test_big_file)

error_message = 'MONTHS_FED_TIME_LIMIT is required but a value was not provided.'
row_18_error = parser_errors.get(row_number=18, error_message=error_message)
assert row_18_error.error_type == ParserErrorCategoryChoices.FIELD_VALUE
assert row_18_error.error_message == error_message
assert row_18_error.content_type.model == 'tanf_t2'
assert row_18_error.object_id is not None
error_message = "14 is not in ['01', '02', '05', '07', '09', '15', '16', '17', '18', '19', '99']. " + \
"or 14 is not blank."
row_118_error = parser_errors.get(row_number=118, error_message=error_message)
assert row_118_error.error_type == ParserErrorCategoryChoices.FIELD_VALUE
assert row_118_error.error_message == error_message
assert row_118_error.content_type.model == 'tanf_t2'
assert row_118_error.object_id is not None

assert TANF_T1.objects.count() == expected_t1_record_count
assert TANF_T2.objects.count() == expected_t2_record_count
Expand Down Expand Up @@ -153,7 +154,7 @@ def test_parse_bad_file_missing_header(bad_file_missing_header):
"""Test parsing of bad_missing_header."""
errors = parse.parse_datafile(bad_file_missing_header)

parser_errors = ParserError.objects.filter(file=bad_file_missing_header)
parser_errors = ParserError.objects.filter(file=bad_file_missing_header).order_by('created_at')

assert parser_errors.count() == 2

Expand All @@ -165,7 +166,7 @@ def test_parse_bad_file_missing_header(bad_file_missing_header):
assert err.content_type is None
assert err.object_id is None
assert errors == {
'header': [parser_errors[1], parser_errors[0]]
'header': list(parser_errors)
}


Expand Down

0 comments on commit 78f108b

Please sign in to comment.