aboutsummaryrefslogtreecommitdiff
path: root/tests/qc/test_header.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-05-18 17:34:55 +0300
committerFrederick Muriuki Muriithi2022-05-18 17:36:16 +0300
commit347ca2fe50225b4736e69bb86d8b278818be40ac (patch)
treedf7fcab96bb0dfc44633e93b5875451dfd1af305 /tests/qc/test_header.py
parent8f32812ce73193366ee00d883fd427c830f5a8e9 (diff)
downloadgn-uploader-347ca2fe50225b4736e69bb86d8b278818be40ac.tar.gz
Remove obsoleted code. Fix linting errors.
Remove the old code that relied on exceptions to parse errors in the uploaded files.
Diffstat (limited to 'tests/qc/test_header.py')
-rw-r--r--tests/qc/test_header.py45
1 files changed, 7 insertions, 38 deletions
diff --git a/tests/qc/test_header.py b/tests/qc/test_header.py
index f860a71..2557e85 100644
--- a/tests/qc/test_header.py
+++ b/tests/qc/test_header.py
@@ -3,42 +3,13 @@ import pytest
from hypothesis import given
from hypothesis import strategies as st
-from quality_control.headers import valid_header
from quality_control.errors import InvalidValue, DuplicateHeading
-from quality_control.errors import DuplicateHeader, InvalidHeaderValue
from quality_control.headers import (
invalid_header, invalid_headings, duplicate_headings)
-@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)
-
-## ============================================================
-
@given(headers=st.lists(st.text(max_size=10), max_size=1))
def test_invalid_header_with_list_of_one_value(headers):
+ """Test `invalid_header` with invalid header row"""
assert invalid_header(0, headers) == InvalidValue(
0, 0, "<TAB>".join(headers),
"The header MUST contain at least 2 columns")
@@ -51,13 +22,12 @@ def test_invalid_headings_with_invalid_inputs(headings):
for col, heading in enumerate(headings, start=2))
@pytest.mark.parametrize(
- "strains,headers", [
- (("BXD1", "BXD2", "BXD3"), ("ProbeSet", "BXD3", "BXD1")),
- (("AStrain", "AnotherStrain", "YetAnotherStrain"),
- ("Individual", "AStrain", "AnotherStrain", "YetAnotherStrain"))])
-def test_invalid_header_with_valid_headers(strains, headers):
+ "headers", [
+ (("ProbeSet", "BXD3", "BXD1")),
+ (("Individual", "AStrain", "AnotherStrain", "YetAnotherStrain"))])
+def test_invalid_header_with_valid_headers(headers):
"Verify that the check for header validity works"
- assert invalid_header(0, headers) == None
+ assert invalid_header(0, headers) is None
@pytest.mark.parametrize(
"strains,headings", [
@@ -76,7 +46,7 @@ def test_invalid_headings_with_valid_headings(strains, headings):
def test_duplicate_headers_with_repeated_column_headings(headers, repeated):
"""Check that parsing fails if any header is duplicated"""
assert duplicate_headings(0, headers) == tuple(
- DuplicateHeading(0, head, cols, (
+ DuplicateHeading(0, cols, head, (
f"Heading '{head}', is repeated in columns "
f"{','.join(str(i) for i in cols)}"))
for head, cols in repeated.items())
@@ -88,4 +58,3 @@ def test_duplicate_headers_with_repeated_column_headings(headers, repeated):
def test_duplicate_headers_with_unique_column_headings(headers):
"""Check that parsing fails if any header is duplicated"""
assert duplicate_headings(0, headers) == tuple()
-