Added test coverage
This commit is contained in:
parent
0e4c6b5d40
commit
a567330a68
|
@ -10,5 +10,4 @@ ENV FLASK_ENV production
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
CMD ["gunicorn", "-b", "0.0.0.0:5000", "my_homepage:create_app()"]
|
CMD ["gunicorn", "-b", "0.0.0.0:4040", "my_homepage:create_app()"]
|
||||||
#CMD ["gunicorn", "-b", "127.0.0.1:5000", "my_homepage:create_app()"]
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
graft flaskr/static
|
graft my_homepage/static
|
||||||
graft flaskr/templates
|
graft my_homepage/templates
|
||||||
global-exclude *.pyc
|
global-exclude *.pyc
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
version: '3.9'
|
version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
|
@ -7,4 +7,4 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "4040:4040"
|
||||||
|
|
|
@ -7,20 +7,13 @@ def create_app(test_config=None):
|
||||||
# create and configure the app
|
# create and configure the app
|
||||||
app = Flask(__name__, instance_relative_config=True)
|
app = Flask(__name__, instance_relative_config=True)
|
||||||
|
|
||||||
#if test_config is None:
|
if test_config is None:
|
||||||
# # load the instance config, if it exists, when not testing
|
# load the instance config, if it exists, when not testing
|
||||||
# app.config.from_pyfile('config.py', silent=True)
|
app.config.from_pyfile('config.py', silent=True)
|
||||||
#else:
|
else:
|
||||||
# # load the test config if passed in
|
# load the test config if passed in
|
||||||
# app.config.from_mapping(test_config)
|
app.config.from_mapping(test_config)
|
||||||
|
|
||||||
## ensure the instance folder exists
|
|
||||||
#try:
|
|
||||||
# os.makedirs(app.instance_path)
|
|
||||||
#except OSError:
|
|
||||||
# pass
|
|
||||||
|
|
||||||
# a simple page that says hello
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
7
setup.cfg
Normal file
7
setup.cfg
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[tool:pytest]
|
||||||
|
testpaths = tests
|
||||||
|
|
||||||
|
[coverage:run]
|
||||||
|
branch = True
|
||||||
|
source =
|
||||||
|
my_homepage
|
17
tests/test_website.py
Normal file
17
tests/test_website.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from my_homepage import create_app
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def app():
|
||||||
|
app = create_app({"TESTING": True})
|
||||||
|
yield app
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def client(app):
|
||||||
|
return app.test_client()
|
||||||
|
|
||||||
|
def test_app(client):
|
||||||
|
response = client.get("/")
|
||||||
|
assert(response.status_code == 200)
|
Loading…
Reference in New Issue
Block a user