Added tests to test continuous MLST despite failure
This commit is contained in:
parent
7bd28db6d4
commit
2843d0d592
@ -5,7 +5,6 @@ from automlst.engine.remote.databases.bigsdb import BIGSdbIndex
|
|||||||
|
|
||||||
def setup_parser(parser: ArgumentParser):
|
def setup_parser(parser: ArgumentParser):
|
||||||
parser.description = "Fetches the latest BIGSdb MLST database definitions."
|
parser.description = "Fetches the latest BIGSdb MLST database definitions."
|
||||||
parser.usage = "test"
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--retrieve-bigsdbs", "-l",
|
"--retrieve-bigsdbs", "-l",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
from Bio import SeqIO
|
from Bio import SeqIO
|
||||||
|
import pytest
|
||||||
from automlst.engine.data.genomics import NamedString
|
from automlst.engine.data.genomics import NamedString
|
||||||
from automlst.engine.data.mlst import Allele, MLSTProfile
|
from automlst.engine.data.mlst import Allele, MLSTProfile
|
||||||
|
from automlst.engine.exceptions.database import NoBIGSdbExactMatchesException
|
||||||
from automlst.engine.remote.databases.bigsdb import BIGSdbIndex, BIGSdbMLSTProfiler
|
from automlst.engine.remote.databases.bigsdb import BIGSdbIndex, BIGSdbMLSTProfiler
|
||||||
|
|
||||||
|
|
||||||
@ -128,6 +130,41 @@ async def test_bigsdb_profile_multiple_strings_same_string_twice():
|
|||||||
assert profile.clonal_complex == "ST-2 complex"
|
assert profile.clonal_complex == "ST-2 complex"
|
||||||
assert profile.sequence_type == "1"
|
assert profile.sequence_type == "1"
|
||||||
|
|
||||||
|
async def test_bigsdb_profile_multiple_strings_fail_second_no_stop():
|
||||||
|
valid_seq = str(SeqIO.read("tests/resources/tohama_I_bpertussis.fasta", "fasta").seq)
|
||||||
|
invalid_seq = str(SeqIO.read("tests/resources/FDAARGOS_1560.fasta", "fasta").seq)
|
||||||
|
dummy_sequences = [NamedString("seq1", valid_seq), NamedString("should_fail", invalid_seq), NamedString("seq3", valid_seq)]
|
||||||
|
async def generate_async_iterable_sequences():
|
||||||
|
for dummy_sequence in dummy_sequences:
|
||||||
|
yield dummy_sequence
|
||||||
|
async with BIGSdbMLSTProfiler(database_api="https://bigsdb.pasteur.fr/api", database_name="pubmlst_bordetella_seqdef", schema_id=3) as dummy_profiler:
|
||||||
|
async for name, profile in dummy_profiler.profile_multiple_strings(generate_async_iterable_sequences()):
|
||||||
|
if name == "should_fail":
|
||||||
|
assert profile is None
|
||||||
|
else:
|
||||||
|
assert profile is not None
|
||||||
|
assert isinstance(profile, MLSTProfile)
|
||||||
|
assert profile.clonal_complex == "ST-2 complex"
|
||||||
|
assert profile.sequence_type == "1"
|
||||||
|
|
||||||
|
async def test_bigsdb_profile_multiple_strings_fail_second_stop():
|
||||||
|
valid_seq = str(SeqIO.read("tests/resources/tohama_I_bpertussis.fasta", "fasta").seq)
|
||||||
|
invalid_seq = str(SeqIO.read("tests/resources/FDAARGOS_1560.fasta", "fasta").seq)
|
||||||
|
dummy_sequences = [NamedString("seq1", valid_seq), NamedString("should_fail", invalid_seq), NamedString("seq3", valid_seq)]
|
||||||
|
async def generate_async_iterable_sequences():
|
||||||
|
for dummy_sequence in dummy_sequences:
|
||||||
|
yield dummy_sequence
|
||||||
|
async with BIGSdbMLSTProfiler(database_api="https://bigsdb.pasteur.fr/api", database_name="pubmlst_bordetella_seqdef", schema_id=3) as dummy_profiler:
|
||||||
|
with pytest.raises(NoBIGSdbExactMatchesException):
|
||||||
|
async for name, profile in dummy_profiler.profile_multiple_strings(generate_async_iterable_sequences(), stop_on_fail=True):
|
||||||
|
if name == "should_fail":
|
||||||
|
pytest.fail("Exception should have been thrown, no exception was thrown.")
|
||||||
|
else:
|
||||||
|
assert profile is not None
|
||||||
|
assert isinstance(profile, MLSTProfile)
|
||||||
|
assert profile.clonal_complex == "ST-2 complex"
|
||||||
|
assert profile.sequence_type == "1"
|
||||||
|
|
||||||
async def test_bigsdb_index_get_schemas_for_bordetella():
|
async def test_bigsdb_index_get_schemas_for_bordetella():
|
||||||
async with BIGSdbIndex() as index:
|
async with BIGSdbIndex() as index:
|
||||||
schemas = await index.get_schemas_for_seqdefdb(seqdef_db_name="pubmlst_bordetella_seqdef")
|
schemas = await index.get_schemas_for_seqdefdb(seqdef_db_name="pubmlst_bordetella_seqdef")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user