aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-04-13 12:26:17 +0300
committerFrederick Muriuki Muriithi2022-04-13 12:26:17 +0300
commitde22890b9c10ece94560dc91a8de2ca3bdb5944b (patch)
tree66fb928458832bfa6a16938f40bc7a7a50491c15
parent1cc86cb4b71fe29b40115813836ca1277c1df859 (diff)
downloadgn-uploader-de22890b9c10ece94560dc91a8de2ca3bdb5944b.tar.gz
Add test for duplicate headers
-rw-r--r--quality_control/errors.py6
-rw-r--r--tests/qc/test_header.py12
2 files changed, 17 insertions, 1 deletions
diff --git a/quality_control/errors.py b/quality_control/errors.py
index 758a300..993748c 100644
--- a/quality_control/errors.py
+++ b/quality_control/errors.py
@@ -12,6 +12,12 @@ class InvalidHeaderValue(Exception):
def __init__(self, *args):
super().__init__(self, *args)
+class DuplicateHeader(Exception):
+ """Raised when a header contains 2 similar headers."""
+
+ def __init__(self, *args):
+ super().__init__(self, *args)
+
class ParseError(Exception):
def __init(self, *args):
super().__init__(*args)
diff --git a/tests/qc/test_header.py b/tests/qc/test_header.py
index 2feac19..a474834 100644
--- a/tests/qc/test_header.py
+++ b/tests/qc/test_header.py
@@ -3,7 +3,7 @@ from hypothesis import given
from hypothesis import strategies as st
from quality_control.headers import valid_header
-from quality_control.errors import InvalidHeaderValue
+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):
@@ -19,3 +19,13 @@ def test_valid_header_errors_with_invalid_headers(headers):
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):
+ with pytest.raises(DuplicateHeader):
+ valid_header(strains, headers)