wundertile/manage.py
2019-04-24 17:51:45 +02:00

63 lines
980 B
Python

"""App entry point"""
import logging.config
import yaml
import coverage
import pytest
from flask.cli import AppGroup
COV = coverage.coverage(
branch=True,
include='app/*',
omit=['tests/*']
)
COV.start()
from app import create_app, db
# with open('logging.yml', 'r') as f:
# logging.config.dictConfig(yaml.load(f))
app = create_app()
database = AppGroup('database')
database.help = 'Development database commands'
@database.command()
def drop_db():
db.drop_all()
db.session.commit()
@database.command()
def recreate_db():
db.drop_all()
db.create_all()
db.session.commit()
@database.command()
def seed_db():
seed()
app.cli.add_command(database)
@app.cli.command()
def test():
exit(pytest.main(['-x', 'tests']))
@app.cli.command()
def test_coverage():
if pytest.main(['-x', 'tests']):
exit(1)
COV.stop()
COV.save()
print('Coverage Summary:')
COV.report()
COV.html_report()
COV.erase()