Skip to content

Commit 608bd46

Browse files
committed
fix plan stages tests
1 parent ea49c00 commit 608bd46

File tree

1 file changed

+57
-45
lines changed

1 file changed

+57
-45
lines changed

tests/core/test_plan_stages.py

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
AfterAllStage,
1313
AuditOnlyRunStage,
1414
PhysicalLayerUpdateStage,
15+
PhysicalLayerSchemaCreationStage,
1516
CreateSnapshotRecordsStage,
1617
BeforeAllStage,
1718
BackfillStage,
@@ -134,18 +135,14 @@ def test_build_plan_stages_basic(
134135
snapshot_a.snapshot_id,
135136
snapshot_b.snapshot_id,
136137
}
137-
# Verify PhysicalLayerUpdateStage
138+
# Verify PhysicalLayerSchemaCreationStage
138139
physical_stage = stages[1]
139-
assert isinstance(physical_stage, PhysicalLayerUpdateStage)
140+
assert isinstance(physical_stage, PhysicalLayerSchemaCreationStage)
140141
assert len(physical_stage.snapshots) == 2
141142
assert {s.snapshot_id for s in physical_stage.snapshots} == {
142143
snapshot_a.snapshot_id,
143144
snapshot_b.snapshot_id,
144145
}
145-
assert {s.snapshot_id for s in physical_stage.snapshots_with_missing_intervals} == {
146-
snapshot_a.snapshot_id,
147-
snapshot_b.snapshot_id,
148-
}
149146
assert physical_stage.deployability_index == DeployabilityIndex.all_deployable()
150147

151148
# Verify BackfillStage
@@ -252,9 +249,9 @@ def test_build_plan_stages_with_before_all_and_after_all(
252249
snapshot_b.snapshot_id,
253250
}
254251

255-
# Verify PhysicalLayerUpdateStage
252+
# Verify PhysicalLayerSchemaCreationStage
256253
physical_stage = stages[2]
257-
assert isinstance(physical_stage, PhysicalLayerUpdateStage)
254+
assert isinstance(physical_stage, PhysicalLayerSchemaCreationStage)
258255
assert len(physical_stage.snapshots) == 2
259256
assert {s.snapshot_id for s in physical_stage.snapshots} == {
260257
snapshot_a.snapshot_id,
@@ -356,13 +353,12 @@ def test_build_plan_stages_select_models(
356353
snapshot_b.snapshot_id,
357354
}
358355

359-
# Verify PhysicalLayerUpdateStage
356+
# Verify PhysicalLayerSchemaCreationStage
360357
physical_stage = stages[1]
361-
assert isinstance(physical_stage, PhysicalLayerUpdateStage)
358+
assert isinstance(physical_stage, PhysicalLayerSchemaCreationStage)
362359
assert len(physical_stage.snapshots) == 1
363360
assert {s.snapshot_id for s in physical_stage.snapshots} == {snapshot_a.snapshot_id}
364361
assert physical_stage.deployability_index == DeployabilityIndex.all_deployable()
365-
assert physical_stage.snapshots_with_missing_intervals == {snapshot_a.snapshot_id}
366362

367363
# Verify BackfillStage
368364
backfill_stage = stages[2]
@@ -446,7 +442,7 @@ def test_build_plan_stages_basic_no_backfill(
446442
stages = build_plan_stages(plan, state_reader, None)
447443

448444
# Verify stages
449-
assert len(stages) == 7
445+
assert len(stages) == 8
450446

451447
# Verify CreateSnapshotRecordsStage
452448
create_snapshot_records_stage = stages[0]
@@ -456,8 +452,17 @@ def test_build_plan_stages_basic_no_backfill(
456452
snapshot_a.snapshot_id,
457453
snapshot_b.snapshot_id,
458454
}
459-
# Verify PhysicalLayerUpdateStage
455+
# Verify PhysicalLayerSchemaCreationStage
460456
physical_stage = stages[1]
457+
assert isinstance(physical_stage, PhysicalLayerSchemaCreationStage)
458+
assert len(physical_stage.snapshots) == 2
459+
assert {s.snapshot_id for s in physical_stage.snapshots} == {
460+
snapshot_a.snapshot_id,
461+
snapshot_b.snapshot_id,
462+
}
463+
464+
# Verify PhysicalLayerUpdateStage
465+
physical_stage = stages[2]
461466
assert isinstance(physical_stage, PhysicalLayerUpdateStage)
462467
assert len(physical_stage.snapshots) == 2
463468
assert {s.snapshot_id for s in physical_stage.snapshots} == {
@@ -466,28 +471,28 @@ def test_build_plan_stages_basic_no_backfill(
466471
}
467472

468473
# Verify BackfillStage
469-
backfill_stage = stages[2]
474+
backfill_stage = stages[3]
470475
assert isinstance(backfill_stage, BackfillStage)
471476
assert backfill_stage.deployability_index == DeployabilityIndex.all_deployable()
472477
assert backfill_stage.snapshot_to_intervals == {}
473478

474479
# Verify EnvironmentRecordUpdateStage
475-
assert isinstance(stages[3], EnvironmentRecordUpdateStage)
476-
assert stages[3].no_gaps_snapshot_names == {snapshot_a.name, snapshot_b.name}
480+
assert isinstance(stages[4], EnvironmentRecordUpdateStage)
481+
assert stages[4].no_gaps_snapshot_names == {snapshot_a.name, snapshot_b.name}
477482

478483
# Verify UnpauseStage
479-
assert isinstance(stages[4], UnpauseStage)
480-
assert {s.name for s in stages[4].promoted_snapshots} == {snapshot_a.name, snapshot_b.name}
484+
assert isinstance(stages[5], UnpauseStage)
485+
assert {s.name for s in stages[5].promoted_snapshots} == {snapshot_a.name, snapshot_b.name}
481486

482487
# Verify VirtualLayerUpdateStage
483-
virtual_stage = stages[5]
488+
virtual_stage = stages[6]
484489
assert isinstance(virtual_stage, VirtualLayerUpdateStage)
485490
assert len(virtual_stage.promoted_snapshots) == 2
486491
assert len(virtual_stage.demoted_snapshots) == 0
487492
assert {s.name for s in virtual_stage.promoted_snapshots} == {'"a"', '"b"'}
488493

489494
# Verify FinalizeEnvironmentStage
490-
assert isinstance(stages[6], FinalizeEnvironmentStage)
495+
assert isinstance(stages[7], FinalizeEnvironmentStage)
491496

492497

493498
def test_build_plan_stages_restatement(
@@ -558,9 +563,9 @@ def test_build_plan_stages_restatement(
558563
# Verify stages
559564
assert len(stages) == 5
560565

561-
# Verify PhysicalLayerUpdateStage
566+
# Verify PhysicalLayerSchemaCreationStage
562567
physical_stage = stages[0]
563-
assert isinstance(physical_stage, PhysicalLayerUpdateStage)
568+
assert isinstance(physical_stage, PhysicalLayerSchemaCreationStage)
564569
assert len(physical_stage.snapshots) == 2
565570
assert {s.snapshot_id for s in physical_stage.snapshots} == {
566571
snapshot_a.snapshot_id,
@@ -679,17 +684,15 @@ def test_build_plan_stages_forward_only(
679684
new_snapshot_b.snapshot_id,
680685
}
681686

682-
# Verify PhysicalLayerUpdateStage
687+
# Verify PhysicalLayerSchemaCreationStage
683688
physical_stage = stages[1]
684-
assert isinstance(physical_stage, PhysicalLayerUpdateStage)
689+
assert isinstance(physical_stage, PhysicalLayerSchemaCreationStage)
685690
assert len(physical_stage.snapshots) == 2
686691
assert {s.snapshot_id for s in physical_stage.snapshots} == {
687692
new_snapshot_a.snapshot_id,
688693
new_snapshot_b.snapshot_id,
689694
}
690-
assert physical_stage.deployability_index == DeployabilityIndex.create(
691-
[new_snapshot_a, new_snapshot_b]
692-
)
695+
assert physical_stage.deployability_index == DeployabilityIndex.all_deployable()
693696

694697
# Verify EnvironmentRecordUpdateStage
695698
assert isinstance(stages[2], EnvironmentRecordUpdateStage)
@@ -808,9 +811,9 @@ def test_build_plan_stages_forward_only_dev(
808811
new_snapshot_b.snapshot_id,
809812
}
810813

811-
# Verify PhysicalLayerUpdateStage
814+
# Verify PhysicalLayerSchemaCreationStage
812815
physical_stage = stages[1]
813-
assert isinstance(physical_stage, PhysicalLayerUpdateStage)
816+
assert isinstance(physical_stage, PhysicalLayerSchemaCreationStage)
814817
assert len(physical_stage.snapshots) == 2
815818
assert {s.snapshot_id for s in physical_stage.snapshots} == {
816819
new_snapshot_a.snapshot_id,
@@ -921,7 +924,7 @@ def _get_snapshots(snapshot_ids: t.List[SnapshotId]) -> t.Dict[SnapshotId, Snaps
921924
stages = build_plan_stages(plan, state_reader, None)
922925

923926
# Verify stages
924-
assert len(stages) == 7
927+
assert len(stages) == 8
925928

926929
# Verify CreateSnapshotRecordsStage
927930
create_snapshot_records_stage = stages[0]
@@ -932,8 +935,20 @@ def _get_snapshots(snapshot_ids: t.List[SnapshotId]) -> t.Dict[SnapshotId, Snaps
932935
new_snapshot_b.snapshot_id,
933936
}
934937

935-
# Verify PhysicalLayerUpdateStage
938+
# Verify PhysicalLayerSchemaCreationStage
936939
physical_stage = stages[1]
940+
assert isinstance(physical_stage, PhysicalLayerSchemaCreationStage)
941+
assert len(physical_stage.snapshots) == 2
942+
assert {s.snapshot_id for s in physical_stage.snapshots} == {
943+
new_snapshot_a.snapshot_id,
944+
new_snapshot_b.snapshot_id,
945+
}
946+
assert physical_stage.deployability_index == DeployabilityIndex.create(
947+
[new_snapshot_a, new_snapshot_b]
948+
)
949+
950+
# Verify PhysicalLayerUpdateStage
951+
physical_stage = stages[2]
937952
assert isinstance(physical_stage, PhysicalLayerUpdateStage)
938953
assert len(physical_stage.snapshots) == 2
939954
assert {s.snapshot_id for s in physical_stage.snapshots} == {
@@ -945,28 +960,28 @@ def _get_snapshots(snapshot_ids: t.List[SnapshotId]) -> t.Dict[SnapshotId, Snaps
945960
)
946961

947962
# Verify AuditOnlyRunStage
948-
audit_only_stage = stages[2]
963+
audit_only_stage = stages[3]
949964
assert isinstance(audit_only_stage, AuditOnlyRunStage)
950965
assert len(audit_only_stage.snapshots) == 1
951966
assert audit_only_stage.snapshots[0].snapshot_id == new_snapshot_a.snapshot_id
952967

953968
# Verify BackfillStage
954-
backfill_stage = stages[3]
969+
backfill_stage = stages[4]
955970
assert isinstance(backfill_stage, BackfillStage)
956971
assert len(backfill_stage.snapshot_to_intervals) == 0
957972

958973
# Verify EnvironmentRecordUpdateStage
959-
assert isinstance(stages[4], EnvironmentRecordUpdateStage)
974+
assert isinstance(stages[5], EnvironmentRecordUpdateStage)
960975

961976
# Verify VirtualLayerUpdateStage
962-
virtual_stage = stages[5]
977+
virtual_stage = stages[6]
963978
assert isinstance(virtual_stage, VirtualLayerUpdateStage)
964979
assert len(virtual_stage.promoted_snapshots) == 2
965980
assert len(virtual_stage.demoted_snapshots) == 0
966981
assert {s.name for s in virtual_stage.promoted_snapshots} == {'"a"', '"b"'}
967982

968983
# Verify FinalizeEnvironmentStage
969-
assert isinstance(stages[6], FinalizeEnvironmentStage)
984+
assert isinstance(stages[7], FinalizeEnvironmentStage)
970985

971986

972987
def test_build_plan_stages_forward_only_ensure_finalized_snapshots(
@@ -1046,7 +1061,7 @@ def test_build_plan_stages_forward_only_ensure_finalized_snapshots(
10461061

10471062
assert len(stages) == 8
10481063
assert isinstance(stages[0], CreateSnapshotRecordsStage)
1049-
assert isinstance(stages[1], PhysicalLayerUpdateStage)
1064+
assert isinstance(stages[1], PhysicalLayerSchemaCreationStage)
10501065
assert isinstance(stages[2], EnvironmentRecordUpdateStage)
10511066
assert isinstance(stages[3], MigrateSchemasStage)
10521067
assert isinstance(stages[4], BackfillStage)
@@ -1120,7 +1135,7 @@ def test_build_plan_stages_removed_model(
11201135
# Verify stages
11211136
assert len(stages) == 5
11221137

1123-
assert isinstance(stages[0], PhysicalLayerUpdateStage)
1138+
assert isinstance(stages[0], PhysicalLayerSchemaCreationStage)
11241139
assert isinstance(stages[1], BackfillStage)
11251140
assert isinstance(stages[2], EnvironmentRecordUpdateStage)
11261141
assert isinstance(stages[3], VirtualLayerUpdateStage)
@@ -1202,7 +1217,7 @@ def test_build_plan_stages_environment_suffix_target_changed(
12021217
# Verify stages
12031218
assert len(stages) == 5
12041219

1205-
assert isinstance(stages[0], PhysicalLayerUpdateStage)
1220+
assert isinstance(stages[0], PhysicalLayerSchemaCreationStage)
12061221
assert isinstance(stages[1], BackfillStage)
12071222
assert isinstance(stages[2], EnvironmentRecordUpdateStage)
12081223
assert isinstance(stages[3], VirtualLayerUpdateStage)
@@ -1303,17 +1318,14 @@ def test_build_plan_stages_indirect_non_breaking_view_migration(
13031318
assert len(stages) == 8
13041319

13051320
assert isinstance(stages[0], CreateSnapshotRecordsStage)
1306-
assert isinstance(stages[1], PhysicalLayerUpdateStage)
1321+
assert isinstance(stages[1], PhysicalLayerSchemaCreationStage)
13071322
assert isinstance(stages[2], BackfillStage)
13081323
assert isinstance(stages[3], EnvironmentRecordUpdateStage)
1309-
assert isinstance(stages[4], MigrateSchemasStage)
1310-
assert isinstance(stages[5], UnpauseStage)
1324+
assert isinstance(stages[4], UnpauseStage)
1325+
assert isinstance(stages[5], BackfillStage)
13111326
assert isinstance(stages[6], VirtualLayerUpdateStage)
13121327
assert isinstance(stages[7], FinalizeEnvironmentStage)
13131328

1314-
migrate_schemas_stage = stages[4]
1315-
assert {s.snapshot_id for s in migrate_schemas_stage.snapshots} == {new_snapshot_c.snapshot_id}
1316-
13171329

13181330
def test_build_plan_stages_virtual_environment_mode_filtering(
13191331
make_snapshot, mocker: MockerFixture

0 commit comments

Comments
 (0)