Files
WonderQ-Project/WonderQ-Admin/tests/test_customer_browse_history_migration.py

24 lines
968 B
Python

from importlib.util import module_from_spec, spec_from_file_location
from pathlib import Path
MIGRATION_PATH = Path(__file__).parents[1] / "alembic" / "versions" / "0036_customer_browse_history.py"
SPEC = spec_from_file_location("customer_browse_history_migration", MIGRATION_PATH)
assert SPEC and SPEC.loader
MIGRATION = module_from_spec(SPEC)
SPEC.loader.exec_module(MIGRATION)
def test_customer_browse_history_migration_is_chained_after_current_head():
assert MIGRATION.revision == "0036_customer_browse_history"
assert MIGRATION.down_revision == "0035_concierge_details_jsonb"
def test_customer_browse_history_table_and_indexes_are_created_only_when_missing():
assert MIGRATION.should_create_table(set()) is True
assert MIGRATION.should_create_table({MIGRATION.TABLE_NAME}) is False
assert MIGRATION.CUSTOMER_HISTORY_INDEXES == {
"ix_CustomerBrowseHistory_customerId",
"ix_CustomerBrowseHistory_customer_visitedAt",
}