Esempio n. 1
0
    def test_check_current_db_revision(self):
        assert not check_current_db_revision()

        create_db()
        assert not check_current_db_revision()

        self._upgrade()
        assert not check_current_db_revision()

        upgrade_db()
        assert check_current_db_revision()
Esempio n. 2
0
def db_handler(args):
    """db_handler."""

    if args.type == 'create':
        create_db()

    if args.type == 'status':
        current_rev = db_revision.current_db_revision()
        print('current_rev', current_rev)

    if args.type == 'upgrade':
        upgrade_db()

    if args.type == 'revision':
        db_revision.new_revision()

    if args.type == 'drop':
        if os.path.exists(DB_FILE_PATH):
            os.remove(DB_FILE_PATH)
Esempio n. 3
0
def db_handler(args):
    """db_handler."""

    if args.type == 'create':
        create_db()

    if args.type == 'status':
        ctx = alembic.migration.MigrationContext.configure(ENGINE.connect())
        current_rev = ctx.get_current_revision()
        print('current_rev', current_rev)

    if args.type == 'upgrade':
        upgrade_db()

    if args.type == 'revision':
        ini_path = os.path.join(PACKAGE_DIR, 'alembic.ini')
        config = Config(ini_path)
        config.set_main_option("script_location",
                               os.path.join(PACKAGE_DIR, 'migration'))
        revision(config)

    if args.type == 'drop':
        os.remove(DB_FILE_PATH)
Esempio n. 4
0
    def setUp(self):
        create_db()
        upgrade_db()

        dir = tempfile.mkdtemp(prefix='chainerui_test_collect_images')
        info_path = os.path.join(dir, '.chainerui_images')

        with open(os.path.join(dir, 'img1_1.png'), 'w') as f:
            f.write('text')
        with open(os.path.join(dir, 'img1_2.png'), 'w') as f:
            f.write('text2')
        with open(os.path.join(dir, 'img2.png'), 'w') as f:
            f.write('text3')

        test_data = [{
            'iteration':
            1000,
            'epoch':
            1,
            'images':
            OrderedDict([
                ('0', 'img1_1.png'),
                ('1', 'img1_2.png'),
            ])
        }, {
            'iteration': 2000,
            'epoch': 2,
            'custom': 'test',
            'images': OrderedDict([
                ('seg', 'img2.png'),
            ])
        }]
        with open(info_path, 'w') as f:
            json.dump(test_data, f)

        self._dir = dir
        self._info_path = info_path
Esempio n. 5
0
def setup_test_db(project_path, project_name):
    create_db()
    upgrade_db()

    # insert test data
    Project.create(project_path, project_name)
Esempio n. 6
0
def setup_test_db():
    create_db()
    upgrade_db()

    # insert test data
    Project.create(TEST_PROJECT_PATH, TEST_PROJECT_NAME)