2019-10-04 18:24:11 +00:00
|
|
|
import os
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
from flask_script import Manager
|
|
|
|
from flask_migrate import Migrate, MigrateCommand
|
|
|
|
|
2019-10-06 05:40:02 +00:00
|
|
|
from database import db
|
|
|
|
from app import create_app
|
|
|
|
app = create_app()
|
2019-10-04 18:24:11 +00:00
|
|
|
|
2019-10-13 17:15:03 +00:00
|
|
|
|
2019-10-04 18:24:11 +00:00
|
|
|
migrate = Migrate(app, db)
|
|
|
|
manager = Manager(app)
|
|
|
|
|
2019-10-13 17:15:03 +00:00
|
|
|
# migrations
|
|
|
|
manager.add_command('db', MigrateCommand)
|
|
|
|
|
2019-10-06 05:40:02 +00:00
|
|
|
from models.Game import Game
|
|
|
|
from models.GameRoom import GameRoom
|
|
|
|
from models.Message import Message
|
|
|
|
from models.Move import Move
|
|
|
|
from models.User import User
|
|
|
|
|
2019-10-04 18:24:11 +00:00
|
|
|
|
2019-10-14 23:53:41 +00:00
|
|
|
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('SQLALCHEMY_DATABASE_URI')
|
2019-10-04 18:24:11 +00:00
|
|
|
@manager.command
|
|
|
|
def test():
|
|
|
|
"""Runs the unit tests without test coverage."""
|
|
|
|
tests = unittest.TestLoader().discover('browser-go-api/tests', pattern='test*.py')
|
|
|
|
result = unittest.TextTestRunner(verbosity=2).run(tests)
|
|
|
|
if result.wasSuccessful():
|
|
|
|
return 0
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
manager.run()
|