From bfc286e6b02e5dd45468ccbfc13d837d46f5d618 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Wed, 12 Feb 2025 14:57:51 +0000 Subject: [PATCH] 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. --- .../data/remote/databases/test_bigsdb.py | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/tests/autobigs/engine/data/remote/databases/test_bigsdb.py b/tests/autobigs/engine/data/remote/databases/test_bigsdb.py index 74414a8..17676df 100644 --- a/tests/autobigs/engine/data/remote/databases/test_bigsdb.py +++ b/tests/autobigs/engine/data/remote/databases/test_bigsdb.py @@ -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): name, profile = name_profile.name, name_profile.mlst_profile + assert profile is not None + assert isinstance(profile, MLSTProfile) if name == "should_fail": - assert profile is None + assert profile.clonal_complex == "unknown" + assert profile.sequence_type == "unknown" else: - assert profile is not None - assert isinstance(profile, MLSTProfile) assert profile.clonal_complex == "ST-2 complex" 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.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 with BIGSdbIndex() as index: schemas = await index.get_schemas_for_seqdefdb(seqdef_db_name="pubmlst_bordetella_seqdef")