|
49 | 49 | _match_deletes_to_data_file, |
50 | 50 | ) |
51 | 51 | from pyiceberg.table.metadata import INITIAL_SEQUENCE_NUMBER, TableMetadataUtil, TableMetadataV2, _generate_snapshot_id |
52 | | -from pyiceberg.table.refs import SnapshotRef |
| 52 | +from pyiceberg.table.refs import SnapshotRef, SnapshotRefType |
53 | 53 | from pyiceberg.table.snapshots import ( |
54 | 54 | MetadataLogEntry, |
55 | 55 | Operation, |
@@ -982,28 +982,43 @@ def test_assert_table_uuid(table_v2: Table) -> None: |
982 | 982 |
|
983 | 983 | def test_assert_ref_snapshot_id(table_v2: Table) -> None: |
984 | 984 | base_metadata = table_v2.metadata |
985 | | - AssertRefSnapshotId(ref="main", snapshot_id=base_metadata.current_snapshot_id).validate(base_metadata) |
| 985 | + AssertRefSnapshotId(ref="main", snapshot_id=base_metadata.current_snapshot_id, ref_type=SnapshotRefType.BRANCH).validate( |
| 986 | + base_metadata |
| 987 | + ) |
986 | 988 |
|
987 | 989 | with pytest.raises(CommitFailedException, match="Requirement failed: current table metadata is missing"): |
988 | | - AssertRefSnapshotId(ref="main", snapshot_id=1).validate(None) |
| 990 | + AssertRefSnapshotId(ref="main", snapshot_id=1, ref_type=SnapshotRefType.BRANCH).validate(None) |
989 | 991 |
|
990 | 992 | with pytest.raises( |
991 | 993 | CommitFailedException, |
992 | 994 | match="Requirement failed: branch main was created concurrently", |
993 | 995 | ): |
994 | | - AssertRefSnapshotId(ref="main", snapshot_id=None).validate(base_metadata) |
| 996 | + AssertRefSnapshotId(ref="main", snapshot_id=None, ref_type=SnapshotRefType.BRANCH).validate(base_metadata) |
995 | 997 |
|
996 | 998 | with pytest.raises( |
997 | 999 | CommitFailedException, |
998 | 1000 | match="Requirement failed: branch main has changed: expected id 1, found 3055729675574597004", |
999 | 1001 | ): |
1000 | | - AssertRefSnapshotId(ref="main", snapshot_id=1).validate(base_metadata) |
| 1002 | + AssertRefSnapshotId(ref="main", snapshot_id=1, ref_type=SnapshotRefType.BRANCH).validate(base_metadata) |
| 1003 | + |
| 1004 | + with pytest.raises( |
| 1005 | + CommitFailedException, |
| 1006 | + match="Requirement failed: branch or tag not_exist_branch is missing, expected 1", |
| 1007 | + ): |
| 1008 | + AssertRefSnapshotId(ref="not_exist_branch", snapshot_id=1, ref_type=SnapshotRefType.BRANCH).validate(base_metadata) |
| 1009 | + |
| 1010 | + with pytest.raises( |
| 1011 | + CommitFailedException, |
| 1012 | + match="Requirement failed: branch or tag not_exist_tag is missing, expected 1", |
| 1013 | + ): |
| 1014 | + AssertRefSnapshotId(ref="not_exist_tag", snapshot_id=1, ref_type=SnapshotRefType.TAG).validate(base_metadata) |
1001 | 1015 |
|
| 1016 | + # existing Tag in metadata: test |
1002 | 1017 | with pytest.raises( |
1003 | 1018 | CommitFailedException, |
1004 | | - match="Requirement failed: branch or tag not_exist is missing, expected 1", |
| 1019 | + match="Requirement failed: tag test can't be changed to type branch", |
1005 | 1020 | ): |
1006 | | - AssertRefSnapshotId(ref="not_exist", snapshot_id=1).validate(base_metadata) |
| 1021 | + AssertRefSnapshotId(ref="test", snapshot_id=3051729675574597004, ref_type=SnapshotRefType.BRANCH).validate(base_metadata) |
1007 | 1022 |
|
1008 | 1023 |
|
1009 | 1024 | def test_assert_last_assigned_field_id(table_v2: Table) -> None: |
|
0 commit comments