Example #1
0
def migration(request):
    """
    Runs migrations before all tests and delete database at the end.
    """
    api, app = app_factory()

    with app.app_context():
        remove_test_db()
        run_migrations()
        request.addfinalizer(app_context(remove_test_db))
Example #2
0
def test_run_migrations_and_class_import(monkeypatch):
    paths = []

    def mock__run(path):
        paths.append(path)

    monkeypatch.setattr(runner, '_run_migration', mock__run)

    runner.run_migrations()
    assert len(paths) != 0

    migration_class = runner._import_migration_class(paths[0])
    assert issubclass(migration_class, base.Migration)
Example #3
0
def test_run_migrations_and_class_import(monkeypatch):
    paths = []

    def mock__run(path):
        paths.append(path)

    monkeypatch.setattr(runner, '_run_migration', mock__run)

    runner.run_migrations()
    assert len(paths) != 0

    migration_class = runner._import_migration_class(paths[0])
    assert issubclass(migration_class, base.Migration)
Example #4
0
    def remove_existing_database(func: Callable, *args, **kwargs):

        with current_app().app_context():
            remove_test_db()

        try:
            output = func(*args, **kwargs)
        except Exception as e:
            raise e
        finally:
            run_migrations()

        return output
Example #5
0
    def remove_existing_database(func: Callable, *args, **kwargs):

        with current_app().app_context():
            remove_test_db()

        try:
            output = func(*args, **kwargs)
        except Exception as e:
            raise e
        finally:
            run_migrations()

        return output
Example #6
0
def migrate():
    print('Running migrations')
    run_migrations()
    print('DONE')