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
|
"""Test the parsing of headers"""
import pytest
from hypothesis import given
from hypothesis import strategies as st
from quality_control.headers import valid_header
from quality_control.errors import DuplicateHeader, InvalidHeaderValue
@given(headers=st.lists(st.text(max_size=10)))
def test_valid_header_errors_with_invalid_headers(headers):
"Verify that the check for header validity works"
with pytest.raises(InvalidHeaderValue):
valid_header(("BXD1", "BXD2", "BXD3"), headers)
@pytest.mark.parametrize(
"strains,headers", [
(("BXD1", "BXD2", "BXD3"), ("ProbeSet", "BXD3", "BXD1")),
(("AStrain", "AnotherStrain", "YetAnotherStrain"),
("Individual", "AStrain", "AnotherStrain", "YetAnotherStrain"))])
def test_valid_header_strains_passes_with_valid_headers(strains, headers):
"Verify that the check for header validity works"
assert valid_header(strains, headers)
@pytest.mark.parametrize(
"strains,headers", [
(("BXD1", "BXD2", "BXD3"), ("ProbeSet", "BXD3", "BXD1", "BXD1")),
(("AStrain", "AnotherStrain", "YetAnotherStrain"),
("Individual", "AStrain", "AnotherStrain", "YetAnotherStrain",
"AStrain"))])
def test_valid_header_fails_with_duplicate_headers(strains, headers):
"""Check that parsing fails if any header is duplicated"""
with pytest.raises(DuplicateHeader):
valid_header(strains, headers)
|