diff options
author | Frederick Muriuki Muriithi | 2022-04-13 15:11:17 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-04-13 15:11:17 +0300 |
commit | 8954890bd7410d79ce151196f406b8e1b6985238 (patch) | |
tree | 4c1a6a44af9a518d13d6b3ba8813895fa4e068b6 /tests | |
parent | 6804b610266d0804dd5c391f5171943429c285cd (diff) | |
download | gn-uploader-8954890bd7410d79ce151196f406b8e1b6985238.tar.gz |
Implement remaining file parsing tests
* Implement remaining file parsing tests and some helpers functions
needed for ensuring the tests work.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conftest.py | 9 | ||||
-rw-r--r-- | tests/qc/test_parsing.py | 29 | ||||
-rw-r--r-- | tests/test_data/duplicated_headers_no_data_errors.tsv (renamed from tests/test_data/we_found_no_errors_in_your_file.tsv) | 0 |
3 files changed, 24 insertions, 14 deletions
diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..0cdba3e --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,9 @@ +from functools import reduce + +import pytest + +from quality_control.parsing import strain_names, parse_strains + +@pytest.fixture(scope="session") +def strains(): + return strain_names(parse_strains("strains.csv")) diff --git a/tests/qc/test_parsing.py b/tests/qc/test_parsing.py index 14cfbde..be13d9b 100644 --- a/tests/qc/test_parsing.py +++ b/tests/qc/test_parsing.py @@ -11,37 +11,38 @@ from quality_control.parsing import FileType, parse_file ("tests/test_data/average.tsv", FileType.STANDARD_ERROR), ("tests/test_data/standarderror_1_error_at_end.tsv", FileType.AVERAGE), ("tests/test_data/standarderror.tsv", FileType.AVERAGE), - ("tests/test_data/we_found_no_errors_in_your_file.tsv", + ("tests/test_data/duplicated_headers_no_data_errors.tsv", FileType.STANDARD_ERROR),)) -def test_parse_file_fails_with_wrong_filetype_declaration(filepath, filetype): +def test_parse_file_fails_with_wrong_filetype_declaration(filepath, filetype, strains): with pytest.raises(ParseError): - for line in parse_file(filepath, filetype, "strains.csv"): + for line in parse_file(filepath, filetype, strains): pass @pytest.mark.parametrize( "filepath,filetype", (("tests/test_data/average_crlf.tsv", FileType.AVERAGE), ("tests/test_data/average.tsv", FileType.AVERAGE), - ("tests/test_data/standarderror.tsv", FileType.STANDARD_ERROR), - ("tests/test_data/we_found_no_errors_in_your_file.tsv", FileType.AVERAGE))) -def test_parse_file_passes_with_valid_files(filepath, filetype): - assert False, "Not Implemented" + ("tests/test_data/standarderror.tsv", FileType.STANDARD_ERROR))) +def test_parse_file_passes_with_valid_files(filepath, filetype, strains): + for line in parse_file(filepath, filetype, strains): + assert bool(line) @pytest.mark.parametrize( "filepath,filetype", (("tests/test_data/average_large.tsv", FileType.AVERAGE), ("tests/test_data/average.tsv", FileType.AVERAGE), - ("tests/test_data/standarderror.tsv", FileType.STANDARD_ERROR), - ("tests/test_data/we_found_no_errors_in_your_file.tsv", FileType.AVERAGE))) -def test_parse_file_works_with_large_files(filepath, filetype): - assert False, "Not Implemented" + ("tests/test_data/standarderror.tsv", FileType.STANDARD_ERROR))) +def test_parse_file_works_with_large_files(filepath, filetype, strains): + for line in parse_file(filepath, filetype, strains): + assert bool(line) @pytest.mark.parametrize( "filepath,filetype", (("tests/test_data/average_error_at_end_200MB.tsv", FileType.AVERAGE), - ("tests/test_data/standarderror_1_error_at_end.tsv", FileType.STANDARD_ERROR))) -def test_parse_file_raises_exception_on_error_in_file(filepath, filetype): + ("tests/test_data/standarderror_1_error_at_end.tsv", FileType.STANDARD_ERROR), + ("tests/test_data/duplicated_headers_no_data_errors.tsv", FileType.AVERAGE))) +def test_parse_file_raises_exception_on_error_in_file(filepath, filetype, strains): with pytest.raises(ParseError): - for line in parse_file(filepath, filetype, "strains.csv"): + for line in parse_file(filepath, filetype, strains): pass diff --git a/tests/test_data/we_found_no_errors_in_your_file.tsv b/tests/test_data/duplicated_headers_no_data_errors.tsv index a49ed1b..a49ed1b 100644 --- a/tests/test_data/we_found_no_errors_in_your_file.tsv +++ b/tests/test_data/duplicated_headers_no_data_errors.tsv |