-
Notifications
You must be signed in to change notification settings - Fork 1
/
manage.py
38 lines (28 loc) · 973 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
import unittest
import os
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from apis import app, db
from apis.v2.models.blacklist import Blacklist
from apis.v2.models.business import BusinessModel
from apis.v2.models.review import ReviewModel
from apis.v2.models.user import User
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
@manager.command
def migrator():
run = 'python manage.py db'
if not os.path.isdir('./migrations'):
os.system('{} init'.format(run))
os.system('{} migrate'.format(run))
os.system('{} upgrade'.format(run))
@manager.command
def test():
tests = unittest.TestLoader().discover('apis/v2', pattern='test*.py')
result = unittest.TextTestRunner(verbosity=2).run(tests)
# if result.wasSuccessful() return 0 else 1
# return the opposite boolean
return not result.wasSuccessful()
if __name__ == '__main__':
manager.run()