Skip to content

Commit 04f86fa

Browse files
committed
Cover variable catalog bijection gate
1 parent 0f3c885 commit 04f86fa

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎tests/test_inplace_transform.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,3 +654,33 @@ def test_schema_installer_upgrades_legacy_apply_audit_columns(catalog) -> None:
654654
database_url=url, dataset_id=dataset_id, kind="core",
655655
)["dataset"]["dataset_id"] == dataset_id
656656

657+
def test_public_apply_rejects_divergent_variable_mapping_before_mutation(
658+
catalog,
659+
) -> None:
660+
url, path, dataset_id, table_name = catalog
661+
connection = sqlite3.connect(path)
662+
deleted = connection.execute("DELETE FROM variable_catalog")
663+
assert deleted.rowcount == 1
664+
connection.commit()
665+
before = connection.execute(
666+
f'SELECT score FROM "{table_name}" ORDER BY __case_ordinal'
667+
).fetchall()
668+
669+
with pytest.raises(
670+
openstatspec.UnsupportedOperationError,
671+
match="explicit catalog initialization",
672+
):
673+
openstatspec.apply_spss_in_place(
674+
database_url=url,
675+
dataset_id=dataset_id,
676+
source_text="VARIABLE LABELS score 'Changed'.",
677+
actor="test-agent",
678+
)
679+
680+
assert connection.execute(
681+
f'SELECT score FROM "{table_name}" ORDER BY __case_ordinal'
682+
).fetchall() == before
683+
assert connection.execute(
684+
"SELECT COUNT(*) FROM transformation_apply"
685+
).fetchone() == (0,)
686+

0 commit comments

Comments
 (0)