From cdd4dc456e56bb4eb055e1cb7f2518d45fb3bfb9 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Sat, 20 Jan 2024 09:57:23 +0300 Subject: 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 --- tests/conftest.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'tests') 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" -- cgit v1.2.3