-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
43 lines (30 loc) · 1007 Bytes
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Script manage migration and server running."""
from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand
from bucketlist_api import models, create_app, db
from bucketlist_api.api import app
import nose
manager = Manager(app)
migrate = Migrate(app, db)
@manager.command
def drop():
"Drops database tables"
if prompt_bool("Are you sure you want to lose all your data"):
db.drop_all()
@manager.command
def create(default_data=True, sample_data=False):
"Creates database tables from sqlalchemy models"
db.create_all()
@manager.command
def test():
"""Run test for the application."""
test_response = nose.run(argv=['--with-coverage'])
return test_response
@manager.shell
def make_shell_context():
"""Create a Python Shell to test application."""
return dict(app=app, db=db, models=models)
manager.add_command('db', MigrateCommand)
manager.add_command("runserver", Server())
if __name__ == '__main__':
manager.run()