From d70dbd0addb861aa37c2f2574a537319a75411c7 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 21 Apr 2022 10:24:29 +0300 Subject: Collect all the errors Build a function to collect all the parsing errors into a "sequence" of dict objects containing the issues found. --- tests/qc/test_error_collection.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/qc/test_error_collection.py (limited to 'tests') diff --git a/tests/qc/test_error_collection.py b/tests/qc/test_error_collection.py new file mode 100644 index 0000000..c45803a --- /dev/null +++ b/tests/qc/test_error_collection.py @@ -0,0 +1,30 @@ +import pytest + +from quality_control.parsing import FileType, parse_errors + +@pytest.mark.slow +@pytest.mark.parametrize( + "filepath,filetype,seek_pos", + (("tests/test_data/average_crlf.tsv", FileType.AVERAGE, 0), + ("tests/test_data/average_error_at_end_200MB.tsv", FileType.AVERAGE, + 205500004 # Skip first 500K lines + ), + ("tests/test_data/average.tsv", FileType.AVERAGE, 0), + ("tests/test_data/standarderror_1_error_at_end.tsv", + FileType.STANDARD_ERROR, 0), + ("tests/test_data/standarderror.tsv", FileType.STANDARD_ERROR, 0), + ("tests/test_data/duplicated_headers_no_data_errors.tsv", + FileType.AVERAGE), + )) +def test_parse_errors(filepath, filetype, strains, seek_pos): + """ + Check that only errors are returned, and that certain properties hold for + said errors. + """ + for error in parse_errors(filepath, filetype, strains, seek_pos): + assert isinstance(error, dict) + assert "filepath" in error + assert "filetype" in error + assert "position" in error + assert "error" in error and isinstance(error["error"], str) + assert "message" in error -- cgit v1.2.3