diff options
author | Frederick Muriuki Muriithi | 2022-06-28 15:20:54 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-06-28 15:20:54 +0300 |
commit | e68c807e6598a4087d7c83510ba33c81139f5544 (patch) | |
tree | 1c8d52c686e64cf8751f51d85bf8164ff8b9653c /tests | |
parent | 3eef6d582245c80e274c9e135028de90788a712b (diff) | |
download | gn-uploader-e68c807e6598a4087d7c83510ba33c81139f5544.tar.gz |
Check for inconsistent columns
The number columns in each contents line should be equal to the nember
of columns in the header line.
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 |