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

Increase pytest coverage #1229

Closed
8 tasks done
tunetheweb opened this issue Aug 19, 2020 · 3 comments · Fixed by #1853
Closed
8 tasks done

Increase pytest coverage #1229

tunetheweb opened this issue Aug 19, 2020 · 3 comments · Fixed by #1853
Assignees
Labels
development Building the Almanac tech stack good first issue Good for newcomers
Milestone

Comments

@tunetheweb
Copy link
Member

tunetheweb commented Aug 19, 2020

@Super-Fly did some excellent work in #949 and #1176 to refactor out Python code.

We should look to increase our pytest coverage to test some of these function/helper files.

Latest coverage report (will update this as we merge each PR):

---------- coverage: platform darwin, python 3.8.0-final-0 -----------
Name                            Stmts   Miss  Cover   Missing
-------------------------------------------------------------
server/__init__.py                 39      1    97%   20
server/config.py                   69      0   100%
server/csp.py                       1      0   100%
server/errors.py                   23      7    70%   11, 16-17, 27-28, 33-34
server/feature_policy.py            1      0   100%
server/helpers.py                 126      0   100%
server/language.py                 33      1    97%   10
server/routes.py                   72      0   100%
server/tests/__init__.py            0      0   100%
server/tests/config_test.py        37      0   100%
server/tests/helpers_test.py      184      0   100%
server/tests/routes_test.py        69      0   100%
server/tests/validate_test.py      52      0   100%
server/validate.py                 79      5    94%   39-41, 66-67
-------------------------------------------------------------
TOTAL                             785     14    98%

Required test coverage of 95% reached. Total coverage: 98.22%
================================== 105 passed, 21 warnings in 6.79s ===
@tunetheweb
Copy link
Member Author

tunetheweb commented Nov 20, 2020

Adding a coverage checker in #1555 and Editing the first comment to add the tasks that need completing.

Would love to get to 100% coverage and think that's easily achievable.

We can use # pragma no cover if we absolutely have to to exclude lines we don't need to test (e.g. Flask calls), but ideal we add at least one test for every line and Flask gives guidance on how to test Flask apps.

Put your name beside a file if interested in adding tests for that. Tests go in the src/server/tests folder and should be named with the filename it's test and and _test.py. There's a couple of examples in there already which would be good to start on (helpers_test.py and validate_test.py).

@rviscomi
Copy link
Member

rviscomi commented Dec 1, 2020

Adding test coverage can be thankless work, so I want to make sure to say thank you @AbbyTsai and @bazzadp for working on this!

@tunetheweb
Copy link
Member Author

It appeals to my meticulous nature. 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Building the Almanac tech stack good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants