-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use tox to test the python3-flask template
**What** - Add a sample tox.ini file to the python3-flask. This configuration will run pytest and flake8 for the function handler. The default flake8 is very resticted, only erroring for undefined names and syntax errors. This allows us to lint and test the function during `faas-cli build`, which should simplify CI flows for users. Using `tox` allows th euser to completely customize the test flow without requiring any changes to the template. - Add same test for the echo handler - Include documentationthat describes how to disable Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
- Loading branch information
1 parent
b7057b6
commit fef5672
Showing
4 changed files
with
55 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from .handler import handle | ||
|
||
# Test your handler here | ||
# To disable testing, you need to update the | ||
# tox.ini file, in addition to deleting this file. | ||
|
||
def test_handle(): | ||
assert handle("input") == "input" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# If you would like to disable | ||
# automated testing during faas-cli build, | ||
|
||
# Replace the content of this file with | ||
# [tox] | ||
# skipsdist = true | ||
|
||
# You can also edit, remove, or add additional test steps | ||
# by editing, removing, or adding new testenv sections | ||
|
||
|
||
# find out more about tox: https://tox.readthedocs.io/en/latest/ | ||
[tox] | ||
envlist = lint,test | ||
skipsdist = true | ||
|
||
[testenv:test] | ||
deps = | ||
flask | ||
pytest | ||
-rrequirements.txt | ||
commands = | ||
# run unit tests with pytest | ||
# https://docs.pytest.org/en/stable/ | ||
# configure by adding a pytest.ini to your handler | ||
pytest | ||
|
||
[testenv:lint] | ||
deps = | ||
flake8 | ||
commands = | ||
flake8 . | ||
|
||
[flake8] | ||
count = true | ||
max-line-length = 127 | ||
max-complexity = 10 | ||
statistics = true | ||
# stop the build if there are Python syntax errors or undefined names | ||
select = E9,F63,F7,F82 | ||
show-source = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
flask | ||
waitress | ||
|
||
tox==3.* |