from importlib.util import module_from_spec, spec_from_file_location from pathlib import Path MIGRATION_PATH = Path(__file__).parents[1] / "alembic" / "versions" / "0019_home_wild_archive_images.py" SPEC = spec_from_file_location("home_wild_archive_images_migration", MIGRATION_PATH) assert SPEC and SPEC.loader MIGRATION = module_from_spec(SPEC) SPEC.loader.exec_module(MIGRATION) def test_images_column_is_added_only_when_missing(): assert MIGRATION.should_add_images_column(set()) assert not MIGRATION.should_add_images_column({"id", "image", "images"})