|
37 | 37 | from sqlmesh.utils.dag import DAG |
38 | 38 | from sqlmesh.utils.date import ( |
39 | 39 | now, |
40 | | - now_timestamp, |
41 | 40 | to_date, |
42 | 41 | to_datetime, |
43 | 42 | to_timestamp, |
@@ -1097,53 +1096,6 @@ def test_end_validation(make_snapshot, mocker: MockerFixture): |
1097 | 1096 | assert restatement_prod_plan_builder.build().end == "2022-01-04" |
1098 | 1097 |
|
1099 | 1098 |
|
1100 | | -def test_forward_only_revert_not_allowed(make_snapshot, mocker: MockerFixture): |
1101 | | - snapshot = make_snapshot(SqlModel(name="a", query=parse_one("select 1, ds"))) |
1102 | | - snapshot.categorize_as(SnapshotChangeCategory.BREAKING) |
1103 | | - assert not snapshot.is_forward_only |
1104 | | - |
1105 | | - forward_only_snapshot = make_snapshot(SqlModel(name="a", query=parse_one("select 2, ds"))) |
1106 | | - forward_only_snapshot.categorize_as(SnapshotChangeCategory.BREAKING, forward_only=True) |
1107 | | - forward_only_snapshot.version = snapshot.version |
1108 | | - forward_only_snapshot.unpaused_ts = now_timestamp() |
1109 | | - assert forward_only_snapshot.is_forward_only |
1110 | | - |
1111 | | - context_diff = ContextDiff( |
1112 | | - environment="test_environment", |
1113 | | - is_new_environment=True, |
1114 | | - is_unfinalized_environment=False, |
1115 | | - normalize_environment_name=True, |
1116 | | - create_from="prod", |
1117 | | - create_from_env_exists=True, |
1118 | | - added=set(), |
1119 | | - removed_snapshots={}, |
1120 | | - modified_snapshots={snapshot.name: (snapshot, forward_only_snapshot)}, |
1121 | | - snapshots={snapshot.snapshot_id: snapshot}, |
1122 | | - new_snapshots={}, |
1123 | | - previous_plan_id=None, |
1124 | | - previously_promoted_snapshot_ids=set(), |
1125 | | - previous_finalized_snapshots=None, |
1126 | | - previous_gateway_managed_virtual_layer=False, |
1127 | | - gateway_managed_virtual_layer=False, |
1128 | | - environment_statements=[], |
1129 | | - ) |
1130 | | - |
1131 | | - with pytest.raises( |
1132 | | - PlanError, |
1133 | | - match=r"Attempted to revert to an unrevertable version of model.*", |
1134 | | - ): |
1135 | | - PlanBuilder(context_diff, forward_only=True).build() |
1136 | | - |
1137 | | - # Make sure the plan can be created if a new snapshot version was enforced. |
1138 | | - new_version_snapshot = make_snapshot( |
1139 | | - SqlModel(name="a", query=parse_one("select 1, ds"), stamp="test_stamp") |
1140 | | - ) |
1141 | | - snapshot.categorize_as(SnapshotChangeCategory.BREAKING) |
1142 | | - context_diff.modified_snapshots = {snapshot.name: (new_version_snapshot, forward_only_snapshot)} |
1143 | | - context_diff.new_snapshots = {new_version_snapshot.snapshot_id: new_version_snapshot} |
1144 | | - PlanBuilder(context_diff, forward_only=True).build() |
1145 | | - |
1146 | | - |
1147 | 1099 | def test_forward_only_plan_seed_models(make_snapshot, mocker: MockerFixture): |
1148 | 1100 | snapshot_a = make_snapshot( |
1149 | 1101 | SeedModel( |
|
0 commit comments