def setUpClass(cls): if not CHAINERUI_ENV == 'test': raise NotInTestEnvironmentException( 'set environment variable CHAINERUI_ENV=test ' 'when you run this test') db.init_db() db.setup(test_mode=True)
def db_handler(args): """db_handler.""" if args.type == 'create': if args.db is None: db.init_db() return if not db.setup(url=args.db, echo=args.db_echo): return if args.type == 'status': current_rev = db_revision.current_db_revision() print('The current DB schema version:', current_rev) if args.type == 'upgrade': db.upgrade() if args.type == 'revision': db_revision.new_revision() if args.type == 'drop': if args.db is not None: db.downgrade() db.remove_db()
def test_init_db_duplicated(self): from chainerui import db chainerui_db_dir = os.path.join(self.dir, 'db') db.init_db() assert os.path.exists(chainerui_db_dir) # if the database directory has already created, not occur errors db.init_db() assert os.path.exists(chainerui_db_dir)
def test_setup_default_db(self): from chainerui import db db.init_db() assert db.setup(url=None) assert db._initialized assert db.url == 'sqlite:///' + os.path.join(self.dir, 'db', 'chainerui.db') assert db.engine is not None assert db.session is not None assert db.alembic_config is not None
def setUpClass(cls): if not CHAINERUI_ENV == 'test': raise NotInTestEnvironmentException( 'set environment variable CHAINERUI_ENV=test ' 'when you run this test' ) db.init_db() db.setup(test_mode=True) cls.db_file_path = db._sqlite_db_file_path config = db.alembic_config cls._config = config script_dir = alembic.script.ScriptDirectory.from_config(config) revisions = [sc.revision for sc in script_dir.walk_revisions('base', target.revision)][::-1] for rev in revisions[:-1]: alembic.command.upgrade(config, rev)
def temp_db(): if not CHAINERUI_ENV == 'test': raise NotInTestEnvironmentException( 'set environment variable CHAINERUI_ENV=test ' 'when you run this test') db.init_db()