def setUpClass(cls): database = AioDbFactory(app.config.TEST_DB_URL) database.salt = app.config.SECRET cls.nickname = 'huangsizhe' cls.password = '******' cls.email = "*****@*****.**" db.initialize(database) cls.loop = asyncio.new_event_loop() cls.db = db asyncio.set_event_loop(cls.loop) print("setUp model test context")
def setUpClass(cls): database = AioDbFactory(app.config.TEST_DB_URL) app.config.update({ 'SESSION_TIMEOUT': 10 * 60, 'ACTIVATE_TIMEOUT': 5 * 60 }) database.salt = app.config.SECRET db.initialize(database) app.config.update({ "TEST": True }) cls.client = app.test_client cls.db = db cls.get_redis_pool = partial( aioredis.create_pool, app.config.REDIS_URL ) cls.session_pix = app.name + "::Session::" print("SetUp Api test context")
def _init_db(): """初始化数据库连接.""" database = AioDbFactory(app.config.DB_URL) database.salt = app.config.SECRET db.initialize(database)
def test_mysql(self): assert isinstance( AioDbFactory("mysql://*****:*****@localhost:3306/test"), AioMySQLDatabase)
def test_Failure(self): AioDbFactory("sqlit://")
def test_Postgre(self): assert isinstance( AioDbFactory("postgresql://postgres@localhost:5432/test"), AioPostgreSQLDatabase)
def test_mysql(self): assert isinstance(AioDbFactory("mysql:///test"), AioMySQLDatabase)