Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from tiangolo/testing
Add testing for all the functionality, defaults, configurations, environment variables, app set up, etc.
- Loading branch information
Showing
74 changed files
with
1,034 additions
and
307 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
.mypy_cache | ||
.vscode | ||
|
||
# C extensions | ||
*.so | ||
|
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,23 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
docker = "*" | ||
pytest = "*" | ||
black = "*" | ||
mypy = "*" | ||
pylint = "*" | ||
jupyter = "*" | ||
flake8 = "*" | ||
autoflake = "*" | ||
|
||
[requires] | ||
python_version = "3.6" | ||
|
||
[pipenv] | ||
allow_prereleases = true | ||
|
||
[packages] | ||
flask = "*" |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 +1 @@ | ||
from .endpoints import user | ||
from .endpoints import user # noqa |
12 changes: 4 additions & 8 deletions
12
example-flask-package-python3.7/app/app/api/endpoints/user.py
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,19 +1,15 @@ | ||
from flask import jsonify | ||
|
||
from ..utils import senseless_print | ||
|
||
from ...main import app | ||
from ...core.database import users | ||
from ...main import app | ||
from ..utils import senseless_print | ||
|
||
|
||
@app.route('/users/') | ||
@app.route("/users/") | ||
def route_users(): | ||
users_data = [] | ||
for user in users: | ||
user_data = { | ||
'name': user.name, | ||
'email': user.email, | ||
} | ||
user_data = {"name": user.name, "email": user.email} | ||
users_data.append(user_data) | ||
senseless_print() | ||
return jsonify(users_data) |
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 @@ | ||
def senseless_print(): | ||
# Print something, just to demonstrate how to import modules | ||
print('Senseless print') | ||
print("Senseless print") |
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,10 +1,10 @@ | ||
from ..api import api # noqa | ||
from ..main import app | ||
from ..api import api | ||
|
||
|
||
@app.route("/") | ||
def hello(): | ||
# This could also be returning an index.html | ||
return '''Hello World from Flask in a uWSGI Nginx Docker container with \ | ||
return """Hello World from Flask in a uWSGI Nginx Docker container with \ | ||
Python 3.7 (from the example template), | ||
try also: <a href="/users/">/users/</a>''' | ||
try also: <a href="/users/">/users/</a>""" |
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,6 +1,6 @@ | ||
from ..models.user import User | ||
|
||
users = [ | ||
User('Alice Example', 'alice@example.com'), | ||
User('Bob Example', 'bob@example.com'), | ||
User("Alice Example", "alice@example.com"), | ||
User("Bob Example", "bob@example.com"), | ||
] |
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
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
Oops, something went wrong.