コード例 #1
0
ファイル: test_runner.py プロジェクト: isabella232/snuba
def test_get_pending_migrations() -> None:
    runner = Runner()
    total_migrations = get_total_migration_count()
    assert len(runner._get_pending_migrations()) == total_migrations
    runner.run_migration(MigrationKey(MigrationGroup.SYSTEM,
                                      "0001_migrations"))
    assert len(runner._get_pending_migrations()) == total_migrations - 1
コード例 #2
0
ファイル: test_runner.py プロジェクト: isabella232/snuba
def test_run_all() -> None:
    runner = Runner()
    assert len(runner._get_pending_migrations()) == get_total_migration_count()

    with pytest.raises(MigrationError):
        runner.run_all(force=False)

    runner.run_all(force=True)
    assert runner._get_pending_migrations() == []
コード例 #3
0
ファイル: test_runner.py プロジェクト: isabella232/snuba
def test_reverse_all() -> None:
    runner = Runner()
    all_migrations = runner._get_pending_migrations()
    runner.run_all(force=True)
    for migration in reversed(all_migrations):
        runner.reverse_migration(migration, force=True)

    connection = get_cluster(StorageSetKey.MIGRATIONS).get_query_connection(
        ClickhouseClientSettings.MIGRATE)
    assert connection.execute(
        "SHOW TABLES") == [], "All tables should be deleted"