-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
33 lines (25 loc) · 881 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
from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand
from flask_migrate import upgrade as upgrade_database
from automated_survey_flask import app, db, parsers, prepare_app
prepare_app(environment='development')
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
@manager.command
def test():
"""Run the unit tests."""
import sys
import unittest
prepare_app(environment='test')
upgrade_database()
tests = unittest.TestLoader().discover('.', pattern="*_tests.py")
test_result = unittest.TextTestRunner(verbosity=2).run(tests)
if not test_result.wasSuccessful():
sys.exit(1)
@manager.command
def dbseed():
with open('survey.json') as survey_file:
db.save(parsers.survey_from_json(survey_file.read()))
if __name__ == "__main__":
manager.run()