Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] add test to confirm failure when summarizing on empty gather #1560

Merged
merged 20 commits into from
Jun 17, 2021
Merged
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions tests/test_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,19 +745,55 @@ def test_label_0(runtmp):
assert "d__Bacteria;p__Bacteroidota;c__Bacteroidia;o__Bacteroidales;f__Bacteroidaceae;g__Phocaeicola;s__Phocaeicola vulgatus" in lin_gather_results[3]
assert "d__Bacteria;p__Bacteroidota;c__Bacteroidia;o__Bacteroidales;f__Bacteroidaceae;g__Prevotella;s__Prevotella copri" in lin_gather_results[4]

## some test ideas to start with -- see test_lca.py for add'l ideas
def test_summarize_empty_gather_results(runtmp):
tax = utils.get_test_data('tax/test.taxonomy.csv')

#creates empty gather result
g_csv = runtmp.output('g.csv')
with open(g_csv, "w") as fp:
fp.write("")
print("g_csv: ", g_csv)

#test below is not working properly: assert statement needs to be moved outside of the with block, but exc.value is empty and im not sure why
hehouts marked this conversation as resolved.
Show resolved Hide resolved
with pytest.raises(ValueError) as exc:
#should fail
runtmp.run_sourmash('tax', 'summarize', g_csv, '--taxonomy-csv', tax)
print("exc.val= ", str(exc.value))
assert "No gather results loaded from "+g_csv in str(exc.value)

assert runtmp.last_result.status == -1


def test_summarize_empty_tax_lineage_input(runtmp):
# print(type(runtmp))
tax_empty = runtmp.output('t.csv')
outcsv = runtmp.output('out.csv')
g_csv = utils.get_test_data('tax/test1.gather.csv')

with open(tax_empty, "w") as fp:
fp.write("")
print("t_csv: ", tax_empty)
import sys

with pytest.raises(ValueError) as exc:
runtmp.run_sourmash('tax', 'summarize', g_csv, '--taxonomy-csv', tax_empty, '--split-identifiers', '-o', outcsv)
hehouts marked this conversation as resolved.
Show resolved Hide resolved
print(f"----------------- [DEBUG]{exc.value}", file=sys.stderr)
if(str(exc.value) == "local variable 'n' referenced before assignment"):
hehouts marked this conversation as resolved.
Show resolved Hide resolved
print("[DEBUG] -------------------- PASSED")
else:
print("FAIL")

print(runtmp.last_result.status)
print(runtmp.last_result.out)
print(runtmp.last_result.err)

assert runtmp.last_result.status != 0


#def test_summarize_empty_gather_results():
# pass
#def test_summarize_bad_gather_results():
# pass
#def test_summarize_empty_lineage_input():
# pass
#def test_summarize_bad_lineage_input():
# pass
#def test_summarize_bad_rank():
# pass
#
#def test_classify_bad_gather_results():
# pass
#def test_classify_bad_lineage_input():
Expand Down