def sqlalchemy_setup(db_uri): engine = create_engine(db_uri) init_sqlalchemy(engine) sqlalchemy_patcher = mock.patch("pyramid_sqlalchemy.includeme", includeme_test) sqlalchemy_patcher.start() return SQLAlchemyTestContext(engine, sqlalchemy_patcher)
def sqlalchemy_setup(db_uri): engine = create_engine(db_uri) init_sqlalchemy(engine) sqlalchemy_patcher = mock.patch('pyramid_sqlalchemy.includeme', includeme_test) sqlalchemy_patcher.start() return SQLAlchemyTestContext(engine, sqlalchemy_patcher)
def setUp(self): self.engine = create_engine(self.db_uri) if self.engine.dialect.name == 'sqlite': self.engine.execute('PRAGMA foreign_keys = ON') init_sqlalchemy(self.engine) if self.create_tables: metadata.create_all() super(DatabaseTestCase, self).setUp() self._sqlalchemy_patcher = mock.patch('pyramid_sqlalchemy.includeme') self._sqlalchemy_patcher.start()
def main(argv=sys.argv): if len(argv) < 2: usage(argv) config_uri = argv[1] options = parse_vars(argv[2:]) setup_logging(config_uri) settings = get_appsettings(config_uri, options=options) engine = engine_from_config(settings, 'sqlalchemy.') init_sqlalchemy(engine) BaseObject.metadata.create_all()
def test_basic_sqlite(self): engine = create_engine('sqlite://') init_sqlalchemy(engine) self.assertTrue(Session.session_factory.kw['bind'] is engine)