Skip to content

Commit

Permalink
[MRG] add test to confirm failure when summarizing on empty gather (#…
Browse files Browse the repository at this point in the history
…1560)

* added summarize on empty gather.csv test

* added empty taxonomy csv test

* fix typo

* Update test_tax.py

* trouble shoot tests

* troubleshooting empty gather test

* fixed, maybe? (#1596)

* trying to pull

* cleaned up test_summarize_empty_gather_tax...

* cleaned test_summarize_empty_gather

* fixed test comments

* removed comment

* Update tests/test_tax.py

Co-authored-by: Tessa Pierce Ward <[email protected]>

* Update tests/test_tax.py

Co-authored-by: Tessa Pierce Ward <[email protected]>

* updated empty-gather test

Co-authored-by: Tessa Pierce Ward <[email protected]>
Co-authored-by: C. Titus Brown <[email protected]>
  • Loading branch information
3 people authored Jun 17, 2021
1 parent 24bea0f commit bee47fd
Showing 1 changed file with 39 additions and 8 deletions.
47 changes: 39 additions & 8 deletions tests/test_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,19 +795,50 @@ 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)

#FIXME: currently throwing a valueError
runtmp.run_sourmash('tax', 'summarize', g_csv, '--taxonomy-csv', tax)

assert f"No gather results loaded from {g_csv}" in str(runtmp.last_result.err)
assert runtmp.last_result.status == -1

def test_summarize_empty_tax_lineage_input(runtmp):
# print(type(runtmp))
tax_empty = runtmp.output('t.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)
# assert f"No taxonomic assignments loaded from {tax_empty}" in str(exc.value)
# if(str(exc.value) == "local variable 'n' referenced before assignment"):
# print("[DEBUG] -------------------- PASSED")
# else:
# print("FAIL")
assert f"No taxonomic assignments loaded from {tax_empty}" in str(runtmp.last_result.err)
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

0 comments on commit bee47fd

Please sign in to comment.