from importlib.util import module_from_spec, spec_from_file_location from pathlib import Path MIGRATION_PATH = Path(__file__).parents[1] / "alembic" / "versions" / "0020_home_team_building_details.py" SPEC = spec_from_file_location("home_team_building_details_migration", MIGRATION_PATH) assert SPEC and SPEC.loader MIGRATION = module_from_spec(SPEC) SPEC.loader.exec_module(MIGRATION) def test_detail_columns_are_added_only_when_missing(): assert MIGRATION.missing_detail_columns(set()) == { "detailSubtitle", "detailParagraphs", } assert MIGRATION.missing_detail_columns({"detailSubtitle"}) == {"detailParagraphs"} assert MIGRATION.missing_detail_columns({"detailSubtitle", "detailParagraphs"}) == set()