Skip to content

Commit

Permalink
remove tests for bad zip files 😅
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Dec 18, 2024
1 parent 18f4e07 commit b510d81
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 187 deletions.
34 changes: 0 additions & 34 deletions src/python/tests/test_fastgather.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,40 +427,6 @@ def test_bad_against_2(runtmp, capfd):
)


def test_bad_against_3(runtmp, capfd):
# test with a bad against (a .sig.gz file renamed as zip file)
query = get_test_data("SRR606249.sig.gz")

sig2 = get_test_data("2.fa.sig.gz")
against_zip = runtmp.output("against.zip")
# cp sig2 into against_zip
with open(against_zip, "wb") as fp:
with open(sig2, "rb") as fp2:
fp.write(fp2.read())

g_output = runtmp.output("gather.csv")
p_output = runtmp.output("prefetch.csv")

with pytest.raises(utils.SourmashCommandFailed):
runtmp.sourmash(
"scripts",
"fastgather",
query,
against_zip,
"-o",
g_output,
"--output-prefetch",
p_output,
"-s",
"100000",
)

captured = capfd.readouterr()
print(captured.err)

assert "InvalidArchive" in captured.err


@pytest.mark.xfail(reason="should work, bug")
def test_against_multisigfile(runtmp, zip_against):
# test against a sigfile that contains multiple sketches
Expand Down
55 changes: 0 additions & 55 deletions src/python/tests/test_fastmultigather.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,34 +561,6 @@ def test_sig_query(runtmp, capfd, indexed):
}.issubset(keys)


def test_bad_query(runtmp, capfd, indexed):
# test with a bad query (a .sig.gz file renamed as zip file)
against_list = runtmp.output("against.txt")

sig2 = get_test_data("2.fa.sig.gz")
sig47 = get_test_data("47.fa.sig.gz")
sig63 = get_test_data("63.fa.sig.gz")

query_zip = runtmp.output("query.zip")
# cp sig2 into query_zip
with open(query_zip, "wb") as fp:
with open(sig2, "rb") as fp2:
fp.write(fp2.read())

make_file_list(against_list, [sig2, sig47, sig63])

if indexed:
against_list = index_siglist(runtmp, against_list, runtmp.output("db"))

with pytest.raises(utils.SourmashCommandFailed):
runtmp.sourmash("scripts", "fastmultigather", query_zip, against_list)

captured = capfd.readouterr()
print(captured.err)

assert "InvalidArchive" in captured.err


def test_missing_query(runtmp, capfd, indexed):
# test missing query
query_list = runtmp.output("query.txt")
Expand Down Expand Up @@ -736,33 +708,6 @@ def test_bad_against(runtmp, capfd):
)


def test_bad_against_2(runtmp, capfd, zip_query):
# test with a bad against (a .sig.gz file renamed as zip file)
query = get_test_data("SRR606249.sig.gz")
query_list = runtmp.output("query.txt")
make_file_list(query_list, [query])

sig2 = get_test_data("2.fa.sig.gz")
against_zip = runtmp.output("against.zip")
# cp sig2 into query_zip
with open(against_zip, "wb") as fp:
with open(sig2, "rb") as fp2:
fp.write(fp2.read())

if zip_query:
query_list = zip_siglist(runtmp, query_list, runtmp.output("query.zip"))

with pytest.raises(utils.SourmashCommandFailed):
runtmp.sourmash(
"scripts", "fastmultigather", query_list, against_zip, "-s", "100000"
)

captured = capfd.readouterr()
print(captured.err)

assert "InvalidArchive" in captured.err


def test_empty_against(runtmp, capfd):
# test bad 'against' file - in this case, an empty one
query = get_test_data("SRR606249.sig.gz")
Expand Down
21 changes: 0 additions & 21 deletions src/python/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,27 +429,6 @@ def test_index_zipfile_multiparam(runtmp, capfd, toggle_internal_storage):
runtmp.sourmash("scripts", "index", zipf, "-o", output, toggle_internal_storage)


def test_index_zipfile_bad(runtmp, capfd):
# test with a bad input zipfile (a .sig.gz file renamed as zip file)
sig2 = get_test_data("2.fa.sig.gz")

query_zip = runtmp.output("query.zip")
# cp sig2 into query_zip
with open(query_zip, "wb") as fp:
with open(sig2, "rb") as fp2:
fp.write(fp2.read())

output = runtmp.output("out.csv")

with pytest.raises(utils.SourmashCommandFailed):
runtmp.sourmash("scripts", "index", query_zip, "-o", output)

captured = capfd.readouterr()
print(captured.err)

assert "Couldn't find End Of Central Directory Record" in captured.err


def test_index_check(runtmp, toggle_internal_storage):
# test check index
siglist = runtmp.output("db-sigs.txt")
Expand Down
27 changes: 0 additions & 27 deletions src/python/tests/test_manysearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,33 +556,6 @@ def test_bad_query_2(runtmp, capfd, indexed):
)


def test_bad_query_3(runtmp, capfd):
# test with a bad query (a .sig.gz file renamed as zip file)
against_list = runtmp.output("against.txt")

sig2 = get_test_data("2.fa.sig.gz")
sig47 = get_test_data("47.fa.sig.gz")
sig63 = get_test_data("63.fa.sig.gz")

query_zip = runtmp.output("query.zip")
# cp sig2 into query_zip
with open(query_zip, "wb") as fp:
with open(sig2, "rb") as fp2:
fp.write(fp2.read())

make_file_list(against_list, [sig2, sig47, sig63])

output = runtmp.output("out.csv")

with pytest.raises(utils.SourmashCommandFailed):
runtmp.sourmash("scripts", "multisearch", query_zip, against_list, "-o", output)

captured = capfd.readouterr()
print(captured.err)

assert "InvalidArchive" in captured.err


def test_missing_against(runtmp, capfd, indexed):
# test with a missing against list
query_list = runtmp.output("query.txt")
Expand Down
27 changes: 0 additions & 27 deletions src/python/tests/test_multisearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,33 +628,6 @@ def test_bad_query(runtmp, capfd):
)


def test_bad_query_3(runtmp, capfd):
# test with a bad query (a .sig.gz file renamed as zip file)
against_list = runtmp.output("against.txt")

sig2 = get_test_data("2.fa.sig.gz")
sig47 = get_test_data("47.fa.sig.gz")
sig63 = get_test_data("63.fa.sig.gz")

query_zip = runtmp.output("query.zip")
# cp sig2 into query_zip
with open(query_zip, "wb") as fp:
with open(sig2, "rb") as fp2:
fp.write(fp2.read())

make_file_list(against_list, [sig2, sig47, sig63])

output = runtmp.output("out.csv")

with pytest.raises(utils.SourmashCommandFailed):
runtmp.sourmash("scripts", "multisearch", query_zip, against_list, "-o", output)

captured = capfd.readouterr()
print(captured.err)

assert "InvalidArchive" in captured.err


def test_missing_against(runtmp, capfd, zip_db):
# test with a missing against list
query_list = runtmp.output("query.txt")
Expand Down
23 changes: 0 additions & 23 deletions src/python/tests/test_pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,29 +230,6 @@ def test_bad_query(runtmp, capfd):
)


def test_bad_query_2(runtmp, capfd):
# test with a bad query (a .sig.gz file renamed as zip file)
sig2 = get_test_data("2.fa.sig.gz")
sig47 = get_test_data("47.fa.sig.gz")
sig63 = get_test_data("63.fa.sig.gz")

query_zip = runtmp.output("query.zip")
# cp sig2 into query_zip
with open(query_zip, "wb") as fp:
with open(sig2, "rb") as fp2:
fp.write(fp2.read())

output = runtmp.output("out.csv")

with pytest.raises(utils.SourmashCommandFailed):
runtmp.sourmash("scripts", "pairwise", query_zip, "-o", output)

captured = capfd.readouterr()
print(captured.err)

assert "InvalidArchive" in captured.err


def test_missing_query(runtmp, capfd, zip_db):
# test with a missing query list
query_list = runtmp.output("query.txt")
Expand Down

0 comments on commit b510d81

Please sign in to comment.