57 lines
1.0 KiB
Python
Executable File
57 lines
1.0 KiB
Python
Executable File
# manage.py
|
|
|
|
import unittest
|
|
|
|
from flask_script import Manager
|
|
from flask_migrate import Migrate, MigrateCommand
|
|
|
|
from skeleton.server import app, db
|
|
from skeleton.server.models import User
|
|
|
|
|
|
migrate = Migrate(app, db)
|
|
manager = Manager(app)
|
|
|
|
# migrations
|
|
manager.add_command('db', MigrateCommand)
|
|
|
|
|
|
@manager.command
|
|
def test():
|
|
"""Runs the unit tests without coverage."""
|
|
tests = unittest.TestLoader().discover('tests', pattern='test*.py')
|
|
result = unittest.TextTestRunner(verbosity=2).run(tests)
|
|
if result.wasSuccessful():
|
|
return 0
|
|
else:
|
|
return 1
|
|
|
|
|
|
@manager.command
|
|
def create_db():
|
|
"""Creates the db tables."""
|
|
db.create_all()
|
|
|
|
|
|
@manager.command
|
|
def drop_db():
|
|
"""Drops the db tables."""
|
|
db.drop_all()
|
|
|
|
|
|
@manager.command
|
|
def create_admin():
|
|
"""Creates the admin user."""
|
|
db.session.add(User(email='admin@cisco.com', password='admin', admin=True))
|
|
db.session.commit()
|
|
|
|
|
|
@manager.command
|
|
def create_data():
|
|
"""Creates sample data."""
|
|
pass
|
|
|
|
|
|
if __name__ == '__main__':
|
|
manager.run()
|