aboutsummaryrefslogtreecommitdiff
path: root/tests/qc/test_parsing.py
blob: 14cfbde9886d8f27ca6b782d5f196872212412e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pytest

from quality_control.errors import ParseError
from quality_control.parsing import FileType, parse_file

@pytest.mark.parametrize(
    "filepath,filetype",
    (("tests/test_data/average_crlf.tsv", FileType.STANDARD_ERROR),
     ("tests/test_data/average_error_at_end_200MB.tsv",
      FileType.STANDARD_ERROR),
     ("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",
      FileType.STANDARD_ERROR),))
def test_parse_file_fails_with_wrong_filetype_declaration(filepath, filetype):
    with pytest.raises(ParseError):
        for line in parse_file(filepath, filetype, "strains.csv"):
            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"

@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"


@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):
    with pytest.raises(ParseError):
        for line in parse_file(filepath, filetype, "strains.csv"):
            pass