aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-20 09:57:23 +0300
committerFrederick Muriuki Muriithi2024-01-20 09:57:23 +0300
commitcdd4dc456e56bb4eb055e1cb7f2518d45fb3bfb9 (patch)
tree73248acbadd5014f2b26da41da3098f1ac5ecc1e /tests
parent53b1e7cb181380a24aab4cbc7a9634b2d8dd2d29 (diff)
downloadgn-uploader-cdd4dc456e56bb4eb055e1cb7f2518d45fb3bfb9.tar.gz
Fetch sample/case names from database
Fetch the sample/case names from the database rather than from a static file in the repository. Issue: https://issues.genenetwork.org/issues/quality-control/read-samples-from-database-by-species
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 41dcac1..d441cb9 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -11,13 +11,24 @@ import pytest
import jsonpickle
from qc_app import create_app
-from quality_control.parsing import strain_names
from quality_control.errors import InvalidValue, DuplicateHeading
@pytest.fixture(scope="session")
def strains():
"""Parse the strains once every test session"""
- return strain_names("etc/strains.csv")
+ stainnames = set()
+ with open("etc/strains.csv", encoding="utf8") as strains_file:
+ for idx, line in enumerate(strains_file.readlines()):
+ if idx > 0:
+ parts = line.split()
+ for name in (parts[1], parts[2]):
+ stainnames.add(name.strip())
+ if len(parts) >= 6:
+ alias = parts[5].strip()
+ if alias != "" and alias not in ("P", "\\N"):
+ stainnames.add(alias)
+
+ return tuple(stainnames)
def is_port_in_use(port: int) -> bool:
"Check whether `port` is in use"