Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2693 cat2 messaging cleanup #2963

Merged
merged 31 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dbb1e23
clean option string util
jtimpe Apr 26, 2024
c45c6cb
add friendly name and item num to cat 2
jtimpe Apr 26, 2024
a978900
fix linting
jtimpe Apr 26, 2024
977a0e8
fix a couple tests
jtimpe Apr 26, 2024
ec5e682
Merge branch 'develop' into 2693-cat2-messaging-cleanup
jtimpe May 2, 2024
af563c8
add parens to friendly names
jtimpe May 2, 2024
01af1d2
lint
jtimpe May 2, 2024
1251b1a
Merge branch 'develop' into 2693-cat2-messaging-cleanup
jtimpe May 16, 2024
97aa0ef
fix tests
jtimpe May 16, 2024
ad87ab1
fix more tests
jtimpe May 16, 2024
c2c465f
fix merge duplication
jtimpe May 16, 2024
c0fdd59
Merge branch 'develop' into 2693-cat2-messaging-cleanup
jtimpe May 20, 2024
68789c3
fix tests
jtimpe May 20, 2024
06677a0
lint
jtimpe May 20, 2024
dabda09
Merge branch 'develop' into 2693-cat2-messaging-cleanup
ADPennington May 20, 2024
55a35ef
Merge branch 'develop' into 2693-cat2-messaging-cleanup
ADPennington May 20, 2024
d781700
Merge branch 'develop' into 2693-cat2-messaging-cleanup
ADPennington May 21, 2024
7859cc5
Merge branch 'develop' into 2693-cat2-messaging-cleanup
jtimpe May 22, 2024
9a96a93
fix tets
jtimpe May 22, 2024
725a959
udpate required validator
jtimpe May 29, 2024
81f17ed
Merge branch 'develop' into 2693-cat2-messaging-cleanup
jtimpe May 29, 2024
799ce28
Merge branch 'develop' into 2693-cat2-messaging-cleanup
jtimpe Jun 5, 2024
b49202f
merge develop
jtimpe Jun 5, 2024
20021d4
fix tests
jtimpe Jun 5, 2024
e2f13fa
fix test
jtimpe Jun 5, 2024
b0a605e
Merge branch 'develop' into 2693-cat2-messaging-cleanup
ADPennington Jun 6, 2024
64c3b9f
Merge branch 'develop' into 2693-cat2-messaging-cleanup
ADPennington Jun 26, 2024
b95fb9f
Merge branch 'develop' into 2693-cat2-messaging-cleanup
jtimpe Jun 27, 2024
640fe34
fix tests
jtimpe Jun 27, 2024
89c0f2d
fix lint
jtimpe Jun 27, 2024
07701c8
Merge branch 'develop' into 2693-cat2-messaging-cleanup
elipe17 Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions tdrs-backend/tdpservice/data_files/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def assert_error_report_tanf_file_content_matches_with_friendly_names(response):
assert ws.cell(row=1, column=1).value == "Error reporting in TDP is still in development.We'll" \
+ " be in touch when it's ready to use!For now please refer to the reports you receive via email"
assert ws.cell(row=4, column=COL_ERROR_MESSAGE).value == "if cash amount :873 validator1 passed" \
+ " then number of months T1: 0 is not larger than 0."
+ " then number of months T1 Item -1 number of months: 0 is not larger than 0."

@staticmethod
def assert_error_report_ssp_file_content_matches_with_friendly_names(response):
Expand All @@ -114,7 +114,7 @@ def assert_error_report_ssp_file_content_matches_with_friendly_names(response):

assert ws.cell(row=1, column=1).value == "Error reporting in TDP is still in development.We'll" \
+ " be in touch when it's ready to use!For now please refer to the reports you receive via email"
assert ws.cell(row=4, column=COL_ERROR_MESSAGE).value == "TRAILER record length is 15 characters " + \
assert ws.cell(row=4, column=COL_ERROR_MESSAGE).value == "TRAILER: record length is 15 characters " + \
"but must be 23."

@staticmethod
Expand All @@ -134,8 +134,10 @@ def assert_error_report_file_content_matches_without_friendly_names(response):

assert ws.cell(row=1, column=1).value == "Error reporting in TDP is still in development.We'll" \
+ " be in touch when it's ready to use!For now please refer to the reports you receive via email"
assert ws.cell(row=4, column=COL_ERROR_MESSAGE).value == ("if CASH_AMOUNT :873 validator1 passed then "
"NBR_MONTHS T1: 0 is not larger than 0.")
assert ws.cell(row=4, column=COL_ERROR_MESSAGE).value == (
"if CASH_AMOUNT :873 validator1 passed then "
"NBR_MONTHS T1 Item -1 NBR_MONTHS: 0 is not larger than 0."
)

@staticmethod
def assert_data_file_exists(data_file_data, version, user):
Expand Down
36 changes: 19 additions & 17 deletions tdrs-backend/tdpservice/parsers/test/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def test_parse_bad_test_file(bad_test_file, dfs):

assert err.row_number == 1
assert err.error_type == ParserErrorCategoryChoices.PRE_CHECK
assert err.error_message == 'HEADER record length is 24 characters but must be 23.'
assert err.error_message == 'HEADER: record length is 24 characters but must be 23.'
assert err.content_type is None
assert err.object_id is None
assert errors == {
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_parse_bad_file_missing_header(bad_file_missing_header, dfs):

assert err.row_number == 1
assert err.error_type == ParserErrorCategoryChoices.PRE_CHECK
assert err.error_message == 'HEADER record length is 14 characters but must be 23.'
assert err.error_message == 'HEADER: record length is 14 characters but must be 23.'
assert err.content_type is None
assert err.object_id is None
assert errors == {
Expand Down Expand Up @@ -343,7 +343,7 @@ def test_parse_bad_trailer_file(bad_trailer_file, dfs):

trailer_error = parser_errors.get(row_number=3)
assert trailer_error.error_type == ParserErrorCategoryChoices.PRE_CHECK
assert trailer_error.error_message == 'TRAILER record length is 11 characters but must be 23.'
assert trailer_error.error_message == 'TRAILER: record length is 11 characters but must be 23.'
assert trailer_error.content_type is None
assert trailer_error.object_id is None

Expand All @@ -354,7 +354,7 @@ def test_parse_bad_trailer_file(bad_trailer_file, dfs):
row_errors_list.append(row_error)
assert row_error.error_type == ParserErrorCategoryChoices.PRE_CHECK
assert trailer_error.error_message in [
'TRAILER record length is 11 characters but must be 23.',
'TRAILER: record length is 11 characters but must be 23.',
'T1: Reporting month year None does not match file reporting year:2021, quarter:Q1.']
assert row_error.content_type is None
assert row_error.object_id is None
Expand All @@ -368,7 +368,7 @@ def test_parse_bad_trailer_file(bad_trailer_file, dfs):
row_errors = list(parser_errors.filter(row_number=2).order_by("id"))
length_error = row_errors[0]
assert length_error.error_type == ParserErrorCategoryChoices.PRE_CHECK
assert length_error.error_message == 'T1 record length is 7 characters but must be 156.'
assert length_error.error_message == 'T1: record length is 7 characters but must be 156.'
assert length_error.content_type is None
assert length_error.object_id is None
assert errors == {
Expand Down Expand Up @@ -400,7 +400,7 @@ def test_parse_bad_trailer_file2(bad_trailer_file_2, dfs):

trailer_error_1 = trailer_errors[0]
assert trailer_error_1.error_type == ParserErrorCategoryChoices.PRE_CHECK
assert trailer_error_1.error_message == 'TRAILER record length is 7 characters but must be 23.'
assert trailer_error_1.error_message == 'TRAILER: record length is 7 characters but must be 23.'
assert trailer_error_1.content_type is None
assert trailer_error_1.object_id is None

Expand All @@ -412,7 +412,7 @@ def test_parse_bad_trailer_file2(bad_trailer_file_2, dfs):

row_2_error = parser_errors.get(row_number=2)
assert row_2_error.error_type == ParserErrorCategoryChoices.PRE_CHECK
assert row_2_error.error_message == 'T1 record length is 117 characters but must be 156.'
assert row_2_error.error_message == 'T1: record length is 117 characters but must be 156.'
assert row_2_error.content_type is None
assert row_2_error.object_id is None

Expand All @@ -424,10 +424,10 @@ def test_parse_bad_trailer_file2(bad_trailer_file_2, dfs):
row_3_error_list.append(row_3_error)
assert row_3_error.error_type == ParserErrorCategoryChoices.PRE_CHECK
assert row_3_error.error_message in {
'T1 record length is 7 characters but must be 156.',
'T1: record length is 7 characters but must be 156.',
'T1: Reporting month year None does not match file reporting year:2021, quarter:Q1.',
'T1trash does not start with TRAILER.',
'TRAILER record length is 7 characters but must be 23.',
'TRAILER: record length is 7 characters but must be 23.',
'T1: Case number T1trash cannot contain blanks.',
'Your file does not end with a TRAILER record.'}
assert row_3_error.content_type is None
Expand All @@ -446,7 +446,7 @@ def test_parse_bad_trailer_file2(bad_trailer_file_2, dfs):
row_3_errors = [trailer_errors[2], trailer_errors[3]]
length_error = row_3_errors[0]
assert length_error.error_type == ParserErrorCategoryChoices.PRE_CHECK
assert length_error.error_message == 'T1 record length is 7 characters but must be 156.'
assert length_error.error_message == 'T1: record length is 7 characters but must be 156.'
assert length_error.content_type is None
assert length_error.object_id is None

Expand Down Expand Up @@ -509,7 +509,7 @@ def test_parse_empty_file(empty_file, dfs):

assert err.row_number == 1
assert err.error_type == ParserErrorCategoryChoices.PRE_CHECK
assert err.error_message == 'HEADER record length is 0 characters but must be 23.'
assert err.error_message == 'HEADER: record length is 0 characters but must be 23.'
assert err.content_type is None
assert err.object_id is None
assert errors == {
Expand Down Expand Up @@ -590,7 +590,9 @@ def test_parse_ssp_section1_datafile(ssp_section1_datafile, dfs):

assert err.row_number == 2
assert err.error_type == ParserErrorCategoryChoices.FIELD_VALUE
assert err.error_message == 'M1: 3 is not larger or equal to 1 and smaller or equal to 2.'
assert err.error_message == (
'M1 Item 11 receives subsidized housing: 3 is not larger or equal to 1 and smaller or equal to 2.'
)
assert err.content_type is not None
assert err.object_id is not None
assert parser_errors.count() == 32486
Expand Down Expand Up @@ -884,7 +886,7 @@ def test_parse_bad_ssp_s1_missing_required(bad_ssp_s1__row_missing_required_fiel

trailer_error = parser_errors.get(
row_number=6,
error_message='TRAILER record length is 15 characters but must be 23.'
error_message='TRAILER: record length is 15 characters but must be 23.'
)
assert trailer_error.error_type == ParserErrorCategoryChoices.PRE_CHECK
assert trailer_error.content_type is None
Expand Down Expand Up @@ -1571,9 +1573,9 @@ def test_parse_t2_invalid_dob(t2_invalid_dob_file, dfs):
year_error = parser_errors[1]
digits_error = parser_errors[0]

assert month_error.error_message == "T2: $9 is not a valid month."
assert year_error.error_message == "T2: Year Q897 must be larger than 1900."
assert digits_error.error_message == "T2: Q897$9 3 does not have exactly 8 digits."
assert month_error.error_message == "T2 Item 32 date of birth: $9 is not a valid month."
assert year_error.error_message == "T2 Item 32 date of birth: Year Q897 must be larger than 1900."
assert digits_error.error_message == "T2 Item 32 date of birth: Q897$9 3 does not have exactly 8 digits."


@pytest.mark.django_db
Expand Down Expand Up @@ -1703,7 +1705,7 @@ def test_parse_tanf_section_1_file_with_bad_update_indicator(tanf_section_1_file
error = parser_errors.first()

assert error.error_type == ParserErrorCategoryChoices.FIELD_VALUE
assert error.error_message == "HEADER update indicator: U does not match D."
assert error.error_message == "HEADER Item 10 update indicator: U does not match D."

@pytest.fixture
def tribal_section_4_bad_quarter(stt_user, stt):
Expand Down
16 changes: 15 additions & 1 deletion tdrs-backend/tdpservice/parsers/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from ..fields import Field
from ..row_schema import RowSchema, SchemaManager
from ..util import make_generate_parser_error, create_test_datafile
from ..util import make_generate_parser_error, create_test_datafile, clean_options_string


def passing_validator():
Expand Down Expand Up @@ -525,3 +525,17 @@ def postparse_validator():
assert is_valid is False
assert errors[0].fields_json == {'friendly_name': {'FIRST': 'first', 'SECOND': 'second'}}
assert errors[0].error_message == "an Error"


@pytest.mark.parametrize('options, expected', [
([1, 2, 3, 4], '[1, 2, 3, 4]'),
(['1', '2', '3', '4'], '[1, 2, 3, 4]'),
(['a', 'b', 'c', 'd'], '[a, b, c, d]'),
(('a', 'b', 'c', 'd'), '[a, b, c, d]'),
(["'a'", "'b'", "'c'", "'d'"], "['a', 'b', 'c', 'd']"),
(['words', 'are very', 'weird'], '[words, are very, weird]'),
])
def test_clean_options_string(options, expected):
"""Test `clean_options_string` util func."""
result = clean_options_string(options)
assert result == expected
Loading
Loading