# -*- coding: utf-8 -*-

import os
from flask_migrate import Migrate
from app import create_app, db
from app.models import User, Role, PoseToLocation



app = create_app(os.getenv('FLASK_CONFIG') or 'default')
migrate = Migrate(app, db)


# migrate 的新建 我们需要扫描到这些文件我们才能创建
@app.shell_context_processor
def make_shell_context():
    return dict(db=db, User=User, Role=Role, PoseToLocation=PoseToLocation)


# 单元测试
@app.cli.command()
def test():
    """ run the unit tests """
    import unittest
    tests = unittest.TestLoader().discover('tests')
    unittest.TextTestRunner(verbosity=2).run(tests)

[((11, 10, 11, 26), 'flask_migrate.Migrate', 'Migrate', ({(11, 18, 11, 21): 'app', (11, 23, 11, 25): 'db'}, {}), '(app, db)', False, 'from flask_migrate import Migrate\n'), ((10, 17, 10, 42), 'os.getenv', 'os.getenv', ({(10, 27, 10, 41): '"""FLASK_CONFIG"""'}, {}), "('FLASK_CONFIG')", False, 'import os\n'), ((25, 12, 25, 33), 'unittest.TestLoader', 'unittest.TestLoader', ({}, {}), '()', False, 'import unittest\n'), ((26, 4, 26, 40), 'unittest.TextTestRunner', 'unittest.TextTestRunner', (), '', False, 'import unittest\n')]