async def start_engine(cls): if not database_exists(database_uri()): create_database(database_uri()) self = User() self.engine = await create_engine( user=DATABASE_USERNAME, database=DATABASE_NAME, host=DATABASE_HOST, password=DATABASE_PASSWORD ) await _create_table(self.engine) return self
from cit import create_app from cit.db import db from unittest import TestCase as Base import init_db from sqlalchemy.orm import sessionmaker from sqlalchemy_utils import drop_database from sqlalchemy import create_engine from config import database_uri, Config engine = create_engine(database_uri(Config.host, Config.username, Config.password, 'postgres')) class TestCase(Base): @classmethod def setUpClass(cls): cls.app = create_app('config.TestingConfig') cls.client = cls.app.test_client() cls._ctx = cls.app.test_request_context() cls._ctx.push() session = sessionmaker(bind=engine)() session.connection().connection.set_isolation_level(0) session.execute('CREATE DATABASE cit_test') session.connection().connection.set_isolation_level(1) db.engine.execute('CREATE EXTENSION postgis;') db.engine.execute('CREATE EXTENSION plv8;') db.create_all()
from profapp import create_app from flask import g # from cit.db import db from unittest import TestCase as Base # import init_db from sqlalchemy.orm import sessionmaker from sqlalchemy_utils import drop_database from sqlalchemy import create_engine from config import database_uri, Config, TestingConfig import sqlalchemy.exc as sqlalchemy_exc from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT,\ ISOLATION_LEVEL_READ_COMMITTED import json engine = create_engine( database_uri(Config.host, Config.username, Config.password, 'postgres')) class TestCase(Base): app = None @classmethod def setUpClass(cls): # cls.app = create_app(config='config.TestingConfig') cls.app = create_app(host=args.host, front=args.front, config='config.TestingConfig') cls.client = cls.app.test_client() cls._ctx = cls.app.test_request_context() cls._ctx.push() session = sessionmaker(bind=engine)()
def firstrun(): engine = sa.create_engine(database_uri()) if not database_exists(engine.url): create_database(engine.url)