From 78f108b4ce921e189e09016293d104ed2125b12f Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Mon, 25 Sep 2023 10:15:20 -0600 Subject: [PATCH] - Re-added missing fields - Updating tests --- .../tdpservice/parsers/schema_defs/tanf/t1.py | 38 ++++++++++++++++++- .../tdpservice/parsers/test/test_parse.py | 17 +++++---- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/tdrs-backend/tdpservice/parsers/schema_defs/tanf/t1.py b/tdrs-backend/tdpservice/parsers/schema_defs/tanf/t1.py index af39fcb5d..633cd3857 100644 --- a/tdrs-backend/tdpservice/parsers/schema_defs/tanf/t1.py +++ b/tdrs-backend/tdpservice/parsers/schema_defs/tanf/t1.py @@ -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), diff --git a/tdrs-backend/tdpservice/parsers/test/test_parse.py b/tdrs-backend/tdpservice/parsers/test/test_parse.py index 3798f328a..2a071f686 100644 --- a/tdrs-backend/tdpservice/parsers/test/test_parse.py +++ b/tdrs-backend/tdpservice/parsers/test/test_parse.py @@ -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 @@ -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 @@ -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) }