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

Add unit tests and increase coverage #476

Closed
28 tasks
willingc opened this issue Mar 25, 2020 · 21 comments · May be fixed by #504
Closed
28 tasks

Add unit tests and increase coverage #476

willingc opened this issue Mar 25, 2020 · 21 comments · May be fixed by #504
Labels
easy problem Requires less work than most issues enhancement New feature or request good first issue A relatively isolated issue appropriate for first-time contributors please take this issue Extra attention is needed

Comments

@willingc
Copy link
Contributor

willingc commented Mar 25, 2020

Context
Let's give this great project more test coverage. 💯

Description
If we divide and conquer, we should be able to increase test coverage significantly.

Here's a list of Python files which could benefit from tests or additional tests:

  • align.py - groutr
  • ancestral.py - vanguard737
  • clades.py - willingc
  • distance.py - dharrison-salesforce
  • export.py - 4rund3v
  • export_v1.py
  • export_v2.py
  • filenames.py
  • filter.py - elebow
  • frequencies.py
  • frequency_estimators.py
  • import.py
  • import_beast.py
  • lbi.py
  • mask.py
  • parse.py - dkain
  • reconstruct_sequences.py - zsailor
  • refine.py
  • sequence_traits.py
  • titer_model.py
  • titers.py
  • traits.py - erikguan
  • translate.py - CodeSammich
  • tree.py - cgtopher
  • utils.py
  • validate.py - anouarh
  • validate_export.py
  • version.py - St4rz

To claim a file, edit this message and insert your github username after the filename. Please start by claiming 1 or 2 files. You can always return to claim more.

Once your PR is merged, please check off that the file is covered. Celebrate the increase in tests and coverage and that your contribution makes a difference 🎉

cc/ @huddlej

@willingc willingc added the enhancement New feature or request label Mar 25, 2020
@huddlej huddlej added easy problem Requires less work than most issues good first issue A relatively isolated issue appropriate for first-time contributors please take this issue Extra attention is needed enhancement New feature or request and removed enhancement New feature or request labels Mar 25, 2020
@groutr
Copy link
Contributor

groutr commented Mar 25, 2020

I can work on align.py. I've been reviewing that file for most of the day now.

@elebow
Copy link
Contributor

elebow commented Mar 25, 2020

I'll take a stab at filter.py.

@huddlej
Copy link
Contributor

huddlej commented Mar 26, 2020

Thank you all for signing up to write tests!

In addition to unit tests for individual functions in each module, it would be amazing to have tests for the command line interfaces of major augur modules, too. For example, the filter.py module is also accessible from the command line like so:

augur filter --sequences input.fasta --min-length 25000 --output output.fasta

Testing this type of interface reveals issues with the entire module's data flow even if all of the module's other unit tests are passing. It looks like some folks are using pytest-mock to test these CLIs and it would be great to keep moving in this direction!

@willingc
Copy link
Contributor Author

Absolutely @huddlej. We should be enabling coverage on CI which will indicate for each PR the increase in test coverage by file and by PR ☀️

@jameshadfield
Copy link
Member

jameshadfield commented Mar 27, 2020

In addition to unit tests for functions within each of the python files above (which are great) it would be amazing to have an example of a test of the actual CLI (sub)command itself (e.g. see this comment & this comment). There are a number of invocations of each augur command within ./tests/builds which could be adapted (with simplifications) into such tests. An example of how to best do this would allow future contributions to extend the coverage of such CLI tests.

@dkain
Copy link
Contributor

dkain commented Mar 27, 2020

I can start with parse.py

@anouarh
Copy link

anouarh commented Mar 28, 2020

I can work on validate.py

@cgtopher
Copy link

I can start on tree.py

@ghost
Copy link

ghost commented Mar 30, 2020

I'll start on version.py.

@vanguard737
Copy link

Quick bookkeeping question: augur/filenames.py is in the above list, and augur/ancestral.py is not. However, when I run tests locally, I observe that filenames.py is 100% covered, while ancestral.py is not:

Name                             Stmts   Miss  Cover   Missing
--------------------------------------------------------------
...
augur/ancestral.py                 100     89    11%   44-59, 77-95, 99-113, 118-203
...
augur/filenames.py                   1      0   100%

Confirmed that this reproduces in the Travis build output, e.g. here. Should this issue's worklist be updated accordingly? (I'd do it myself, but wasn't sure if ancestral.py had been left off of this issue on purpose - e.g. out of scope, or covered in another issue elsewhere, etc.)

@willingc
Copy link
Contributor Author

@vanguard737 The omission of ancestral.py was accidental. I will add it now and assign it to you in the first message. Thanks!

@dharrison-salesforce
Copy link

Working down the list, I'll start on distance.py.

@Zsailer
Copy link

Zsailer commented Mar 30, 2020

I'll work on reconstruct_sequences.py

@dharrison-salesforce
Copy link

dharrison-salesforce commented Mar 30, 2020

Is there a good example dataset that can be used with the distance command? Ran through the tb_tutorial and i don't see a distance map I can apply to the tree. I can mock up something based on the examples in the docstrings but I'd prefer to see how it works against a real dataset to sanity check myself.

@erickguan
Copy link

I'll start with traits.py.

@4rund3v
Copy link

4rund3v commented Mar 31, 2020

I can work on export.py

@huddlej
Copy link
Contributor

huddlej commented Apr 2, 2020

@dharrison-salesforce The distance maps described in the docstrings were developed for our seasonal influenza analyses, so the best place to start with real-world data is the nextstrain/seasonal-flu repo. Check out the distances rule in the Snakefile_base for an example of how we run the augur distance command.

If you follow the instructions in the repo's README for setting up example data, you should be able to run a simple build quickly on your local machine. Let me know if you have other questions or issues with these data though. We can fork a separate issue for distances unit tests for further conversation.

@lcwheeler
Copy link

I can work on lbi.py

@CodeSammich
Copy link
Contributor

CodeSammich commented Apr 13, 2020

I can work on translate.py

@dkotschessa
Copy link

Hi there! I came across this project via codetriage, and I was looking for a project to contribute to and write tests. This looks perfect. What is the status of this issue, as I see it says it may be resolved by #504, or is that the issue I should focus on?
Please let me know. Thank you!

@huddlej
Copy link
Contributor

huddlej commented Jan 21, 2021

Test coverage has improved so much thanks to the efforts here. I'm going to close this long-running issue in favor of smaller issues for specific modules that we'll work on in the future. Thank you all!

@huddlej huddlej closed this as completed Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy problem Requires less work than most issues enhancement New feature or request good first issue A relatively isolated issue appropriate for first-time contributors please take this issue Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.