/
manage.py
42 lines (29 loc) · 906 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
# services/users/manage.py
import sys
import unittest
from flask.cli import FlaskGroup
from project import create_app, db
from project.api.models import User
app = create_app()
cli = FlaskGroup(create_app=create_app)
@cli.command('recreate_db')
def recreate_db():
db.drop_all()
db.create_all()
db.session.commit()
@cli.command('seed_db')
def seed_db():
"""Seeds the database."""
db.session.add(User(username='michael', email="hermanmu@gmail.com"))
db.session.add(User(username='michaelherman', email="michael@mherman.org"))
db.session.commit()
@cli.command()
def test():
"""Runs the tests without code coverage"""
tests = unittest.TestLoader().discover('project/tests', pattern='test*.py')
result = unittest.TextTestRunner(verbosity=2).run(tests)
if result.wasSuccessful():
return 0
sys.exit(result)
if __name__ == '__main__':
cli()