def from_list(self, data): """Initialize `data` in `session`. See unittest docs for more details.""" cls = None item = None group = None skip_keys = ['nocommit'] new_data = [] # psycopg2 raises an InternalError instance that is not inherited from # `Exception` and as such requires to be catched too. exceptions = [Exception] if 'postgresql' in db.get_engine().url.drivername: try: from psycopg2 import InternalError exceptions.append(InternalError) except ImportError: pass for group in data: for cls, items in group.iteritems(): if cls in skip_keys: continue if isinstance(cls, basestring) and cls not in skip_keys: cls = self.get_cls(cls) new_data.append({cls.__name__: self.add_classes(cls, items)}) if 'nocommit' not in group: try: db.session.commit() except exceptions: self.log_error(sys.exc_info()[2], data, cls, item) db.session.rollback() return new_data
def begin(self): """We overwrite this method to push in our database setup and to not setup coverage again, since we start it quite a lot earlier. """ engine = db.get_engine() # cleanup the existing databases and recreate them. # Also ensure that a database exists properly. destroy_db(engine) create_db(engine) # create a connection to the existing database self._connection = connection = engine.connect() # setup all database tables. database.init_db(bind=connection, is_test=True) # clear email outbox mail.outbox = [] _internal_modules_to_skip = ('inyoka.core.tasks', ) self.skipModules = [ i for i in sys.modules.keys() if not i.startswith('inyoka') or i in _internal_modules_to_skip ]
def _get_admin_connection(connection): url = connection.engine.url admin_engine = db.get_engine(unicode( URL(url.drivername, url.username, url.password, url.host, url.port, query=url.query)), force_new=True) return admin_engine
def begin(self): """We overwrite this method to push in our database setup and to not setup coverage again, since we start it quite a lot earlier. """ engine = db.get_engine() # cleanup the existing databases and recreate them. # Also ensure that a database exists properly. destroy_db(engine) create_db(engine) # create a connection to the existing database self._connection = connection = engine.connect() # setup all database tables. database.init_db(bind=connection, is_test=True) # clear email outbox mail.outbox = [] _internal_modules_to_skip = ('inyoka.core.tasks',) self.skipModules = [i for i in sys.modules.keys() if not i.startswith('inyoka') or i in _internal_modules_to_skip]
def _get_admin_connection(connection): url = connection.engine.url admin_engine = db.get_engine(unicode(URL(url.drivername, url.username, url.password, url.host, url.port, query=url.query)), force_new=True) return admin_engine