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] provide "protocol" tests for Index, CollectionManifest, and LCA_Database classes #1936

Merged
merged 41 commits into from
Apr 15, 2022

Conversation

ctb
Copy link
Contributor

@ctb ctb commented Apr 8, 2022

Use pytest fixtures and parametrized tests to start building standardized test suites for the Index, CollectionManifest, and LCA_Database classes.

This PR creates three new test files, test_index_protocol.py, test_manifest_protocol.py, and test_lca_db_protocol.py, that use fixtures and parametrized tests to evaluate the various Index, CollectionManifest, and LCA_Database classes. Part of the motivation is to provide a clearer and more uniform test suite for the various Sqlite* classes being introduced in #1808 and #1933.

While Index had a fairly well defined API already, this PR ends up defining (and refactoring) the CollectionManifest and LCA_Database APIs to better test and support core APIs moving forward.
Both LCA_Database and CollectionManifest received a lot of refactoring as a result, but no functionality was changed.

In addition to creating these new tests, this PR fixes a few problems caught by the new tests:

  • fixes len(...) on SBT to only count the number of leaves, not the number of internal nodes;
  • adding a test for sourmash lca rankinfo --minimum-num;
  • fixes a column-off-by-one bug in the LCA tests/GTDB spreadsheet;
  • implements __len__ for LazyLoadedIndex, and adds some correctness checks to constructor;

Remaining issues:

TODO:

Creates problem, and then fixes it;
Fixes #1949

@ctb
Copy link
Contributor Author

ctb commented Apr 8, 2022

@sourmash-bio/devs curious if there is a better approach within the pytest world.

@codecov
Copy link

codecov bot commented Apr 8, 2022

Codecov Report

Merging #1936 (cb54d7d) into latest (6f7eb06) will increase coverage by 0.07%.
The diff coverage is 98.27%.

@@            Coverage Diff             @@
##           latest    #1936      +/-   ##
==========================================
+ Coverage   83.17%   83.25%   +0.07%     
==========================================
  Files         126      126              
  Lines       13954    13989      +35     
  Branches     1910     1913       +3     
==========================================
+ Hits        11606    11646      +40     
+ Misses       2075     2071       -4     
+ Partials      273      272       -1     
Flag Coverage Δ
python 91.22% <98.27%> (+0.08%) ⬆️
rust 65.16% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/sourmash/lca/lca_db.py 91.80% <96.29%> (+0.50%) ⬆️
src/sourmash/index/__init__.py 97.10% <100.00%> (+0.37%) ⬆️
src/sourmash/index/revindex.py 63.46% <100.00%> (ø)
src/sourmash/lca/command_index.py 89.50% <100.00%> (ø)
src/sourmash/lca/command_rankinfo.py 84.61% <100.00%> (+3.22%) ⬆️
src/sourmash/manifest.py 95.09% <100.00%> (+0.84%) ⬆️
src/sourmash/sbt.py 85.37% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f7eb06...cb54d7d. Read the comment docs.

@ctb ctb changed the title [WIP] implement some generic tests for Index classes [WIP] provide "protocol" tests for Index, CollectionManifest, and LCA_Database classes Apr 9, 2022
@ctb ctb changed the title [WIP] provide "protocol" tests for Index, CollectionManifest, and LCA_Database classes [MRG] provide "protocol" tests for Index, CollectionManifest, and LCA_Database classes Apr 11, 2022
@ctb
Copy link
Contributor Author

ctb commented Apr 11, 2022

Ready for review & merge, @sourmash-bio/devs !

tests/test_index.py Outdated Show resolved Hide resolved
Copy link
Contributor

@bluegenes bluegenes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this lgtm! ...but I can't speak to whether there are any better pytest strategies 🤷🏻‍♀️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sourmash index will soon report the wrong number of nodes
2 participants