diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qc/test_error_collection.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/qc/test_error_collection.py b/tests/qc/test_error_collection.py index fe85bb1..ee1e6c2 100644 --- a/tests/qc/test_error_collection.py +++ b/tests/qc/test_error_collection.py @@ -2,8 +2,9 @@ import pytest -from quality_control.errors import InvalidValue, DuplicateHeading from quality_control.parsing import take, FileType, collect_errors +from quality_control.errors import ( + InvalidValue, DuplicateHeading, InconsistentColumns) @pytest.mark.parametrize( "sample,num,expected", @@ -34,3 +35,20 @@ def test_collect_errors(filepath, filetype, strains, count): def __valid_instance(item): return isinstance(item, (InvalidValue, DuplicateHeading)) assert all(__valid_instance(error) for error in results) + +@pytest.mark.parametrize( + "filepath,filetype,expected", + (("tests/test_data/average_inconsistent_columns.tsv", FileType.AVERAGE, + (InconsistentColumns( + 4, 4, 5, "Header row has 4 columns while row 4 has 5 columns"), + InconsistentColumns( + 5, 4, 3, "Header row has 4 columns while row 5 has 3 columns"), + InconsistentColumns( + 6, 4, 7, "Header row has 4 columns while row 6 has 7 columns"))),)) +def test_collect_inconsistent_column_errors(filepath, filetype, strains, expected): + """ + Given: A file with inconsistent columns in certain lines + When: collect_errors is run on the file + Then: All the lines with inconsistent columns are flagged + """ + assert tuple(collect_errors(filepath, filetype, strains)) == expected |