Skip to content

Commit

Permalink
- Corrected merge thrash
Browse files Browse the repository at this point in the history
  • Loading branch information
elipe17 committed Jul 10, 2023
1 parent b905667 commit 29fa8b8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
33 changes: 23 additions & 10 deletions tdrs-backend/tdpservice/parsers/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,38 @@ def parse_datafile_lines(datafile, program_type, section):

def parse_multi_record_line(line, schema, generate_error):
"""Parse and validate a datafile line using MultiRecordRowSchema."""
records = schema.parse_and_validate(line, generate_error)
if schema:
records = schema.parse_and_validate(line, generate_error)

for r in records:
record, record_is_valid, record_errors = r
for r in records:
record, record_is_valid, record_errors = r

if record:
record.save()
if record:
record.save()

return records
return records

return [(None, False, [
generate_error(
schema=None,
error_category=ParserErrorCategoryChoices.PRE_CHECK,
error_message="Record Type is missing from record.",
record=None,
field=None
)
])]


def parse_datafile_line(line, schema, generate_error):
"""Parse and validate a datafile line and save any errors to the model."""
record, record_is_valid, record_errors = schema.parse_and_validate(line, generate_error)
if schema:
record, record_is_valid, record_errors = schema.parse_and_validate(line, generate_error)

if record:
record.save()

if record:
record.save()
return record_is_valid, record_errors

return record_is_valid, record_errors
return (False, [
generate_error(
schema=None,
Expand Down
1 change: 1 addition & 0 deletions tdrs-backend/tdpservice/parsers/test/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def test_parse_small_correct_file(test_datafile, dfs):
def test_parse_section_mismatch(test_datafile, dfs):
"""Test parsing of small_correct_file where the DataFile section doesn't match the rawfile section."""
test_datafile.section = 'Closed Case Data'
test_datafile.save()

dfs.datafile = test_datafile
dfs.save()
Expand Down

0 comments on commit 29fa8b8

Please sign in to comment.