46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
from scripts.alembic_preflight import AlembicPreflightResult
|
|
|
|
|
|
def test_alembic_preflight_action_for_current_version():
|
|
result = AlembicPreflightResult(
|
|
has_alembic_version=True,
|
|
business_table_count=12,
|
|
current_revision="002",
|
|
head_revision="002",
|
|
)
|
|
|
|
assert result.action == "upgrade_head_noop_or_verify"
|
|
|
|
|
|
def test_alembic_preflight_action_for_old_version():
|
|
result = AlembicPreflightResult(
|
|
has_alembic_version=True,
|
|
business_table_count=12,
|
|
current_revision="001",
|
|
head_revision="002",
|
|
)
|
|
|
|
assert result.action == "upgrade_head"
|
|
|
|
|
|
def test_alembic_preflight_action_for_existing_tables_without_version():
|
|
result = AlembicPreflightResult(
|
|
has_alembic_version=False,
|
|
business_table_count=12,
|
|
current_revision=None,
|
|
head_revision="002",
|
|
)
|
|
|
|
assert result.action == "stamp_head_then_upgrade_head"
|
|
|
|
|
|
def test_alembic_preflight_action_for_empty_database():
|
|
result = AlembicPreflightResult(
|
|
has_alembic_version=False,
|
|
business_table_count=0,
|
|
current_revision=None,
|
|
head_revision="002",
|
|
)
|
|
|
|
assert result.action == "upgrade_head_empty_database"
|