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 cli tests #44

Open
mjhea0 opened this issue Apr 4, 2018 · 1 comment
Open

add cli tests #44

mjhea0 opened this issue Apr 4, 2018 · 1 comment

Comments

@mjhea0
Copy link
Contributor

mjhea0 commented Apr 4, 2018

https://www.reddit.com/r/flask/comments/89f6by/af_how_do_i_test_my_cli_scripts/

@jugmac00
Copy link

jugmac00 commented Mar 11, 2019

Some examples what to test...

Let's take the drop_db function from the manage.py module. I would not push this to production without a proper test. For what to test there are different opinions.

First, kind a "smoke test" - test for a 0 exit code.

Second, create a db via fixture, use the drop_db cli command, assert db is gone.

Third, if you like @sandimetz 's testing matrix (cf https://www.youtube.com/watch?v=URSWYvyc42M ), and you do not want to test outgoing commands (ie the db.drop_all() call), you'd have to create a mock and assert db.drop_all was called.

Fortunately, Click makes testing easy:
http://click.palletsprojects.com/en/7.x/testing/

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

No branches or pull requests

2 participants