cookiecutter-flask-skeleton
cookiecutter-flask-skeleton copied to clipboard
add cli tests
https://www.reddit.com/r/flask/comments/89f6by/af_how_do_i_test_my_cli_scripts/
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/