aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--quality_control/errors.py11
-rw-r--r--quality_control/headers.py7
-rw-r--r--tests/qc/test_header.py21
3 files changed, 36 insertions, 3 deletions
diff --git a/quality_control/errors.py b/quality_control/errors.py
index 961ce8e..a77039b 100644
--- a/quality_control/errors.py
+++ b/quality_control/errors.py
@@ -3,6 +3,11 @@
class InvalidValue(Exception):
"""Raised when a function encounters an invalid value"""
- def __init__(self, args):
- Exception.__init__(self, args)
-
+ def __init__(self, *args):
+ Exception.__init__(self, *args)
+
+class InvalidHeaderValue(Exception):
+ """Raised when a header contains values not in the reference file."""
+
+ def __init__(self, *args):
+ Exception.__init__(self, *args)
diff --git a/quality_control/headers.py b/quality_control/headers.py
new file mode 100644
index 0000000..b8ff160
--- /dev/null
+++ b/quality_control/headers.py
@@ -0,0 +1,7 @@
+"""Validate the headers"""
+
+from quality_control.errors import InvalidHeaderValue
+
+def valid_header(strains, headers):
+ "Return the valid headers with reference to strains or throw an error"
+ return None
diff --git a/tests/qc/test_header.py b/tests/qc/test_header.py
new file mode 100644
index 0000000..2feac19
--- /dev/null
+++ b/tests/qc/test_header.py
@@ -0,0 +1,21 @@
+import pytest
+from hypothesis import given
+from hypothesis import strategies as st
+
+from quality_control.headers import valid_header
+from quality_control.errors import 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)