Updated test cases to reflect changes in codebase

MLSTProfile will always return a value, even if there were no exact matches.

Removed a test case specifically testing for stopping on failure, which is a removed feature.
This commit is contained in:
Harrison Deng 2025-02-12 14:57:51 +00:00
parent a88225fcff
commit bfc286e6b0

View File

@ -186,11 +186,12 @@ async def test_bigsdb_profile_multiple_strings_exactmatch_fail_second_no_stop():
async for name_profile in dummy_profiler.profile_multiple_strings(generate_async_iterable_sequences(), True): async for name_profile in dummy_profiler.profile_multiple_strings(generate_async_iterable_sequences(), True):
name, profile = name_profile.name, name_profile.mlst_profile name, profile = name_profile.name, name_profile.mlst_profile
assert profile is not None
assert isinstance(profile, MLSTProfile)
if name == "should_fail": if name == "should_fail":
assert profile is None assert profile.clonal_complex == "unknown"
assert profile.sequence_type == "unknown"
else: else:
assert profile is not None
assert isinstance(profile, MLSTProfile)
assert profile.clonal_complex == "ST-2 complex" assert profile.clonal_complex == "ST-2 complex"
assert profile.sequence_type == "1" assert profile.sequence_type == "1"
@ -214,25 +215,6 @@ async def test_bigsdb_profile_multiple_strings_nonexact_second_no_stop():
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_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 OnlineBIGSdbMLSTProfiler(database_api="https://bigsdb.pasteur.fr/api", database_name="pubmlst_bordetella_seqdef", schema_id=3) as dummy_profiler:
with pytest.raises(NoBIGSdbMatchesException):
async for named_profile in dummy_profiler.profile_multiple_strings(generate_async_iterable_sequences(), stop_on_fail=True):
name, profile = named_profile.name, named_profile.mlst_profile
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")