Пример #1
0
 def setUp(self):
     """
     初始化测试
     """
     self.app = create_app('testing')
     self.app.config.update(SERVER_NAME='localhost:5000', debug=False)
     self.app.testing = True
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     Role.insert_roles()
     self.client = self.app.test_client()
Пример #2
0
 def setUp(self):
     """
     初始化测试
     """
     self.app = create_app('testing')
     self.app.config.update(
         SERVER_NAME = 'localhost:5000',
         debug = False
     )
     self.app.testing = True
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     Role.insert_roles()
     self.client = self.app.test_client()
Пример #3
0
 def setUp(self):
     """
     初始化测试
     """
     self.app = create_app("testing")
     self.app.config.update(SERVER_NAME='localhost:5000', debug=False)
     self.app.testing = True
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     Role.insert_roles()
     CourseTypes.generate_fake()
     CourseCategories.generate_fake()
     CoursesSubCategories.generate_fake()
     # User.generate_fake()
     # Courses.generate_fake()
     # Tips.generate_fake()
     # Comments.generate_fake()
     # CourseQuestion.generate_fake()
     # Answer.generate_fake()
     # Tags.generate_fake()
     self.client = self.app.test_client()
Пример #4
0
from flask.ext.script import Manager, Shell
from flask.ext.migrate import Migrate, MigrateCommand
# from flask.ext.admin import Admin
# from flask.ext.admin.contrib.sqla import ModelView
from xueer import create_app, db
from xueer.models import Permission, Role, User, AnonymousUser, Courses, CourseCategories, \
    CourseTypes, Comments, Teachers, Tags


# 编码设置
reload(sys)
sys.setdefaultencoding('utf-8')


# use create_app to create flask app
app = create_app(os.environ.get('XUEER_CONFIG') or 'default')


manager = Manager(app)
migrate = Migrate(app, db)


# admin = Admin(app, name="")


def make_shell_context():
    """自动加载环境"""
    return dict(
        app=app,
        db=db,
        Permission=Permission,