|
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, SnapshotRefType |
| 52 | +from pyiceberg.table.refs import MAIN_BRANCH, SnapshotRef, SnapshotRefType |
53 | 53 | from pyiceberg.table.snapshots import ( |
54 | 54 | MetadataLogEntry, |
55 | 55 | Operation, |
@@ -982,34 +982,31 @@ 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_BRANCH, snapshot_id=base_metadata.current_snapshot_id).validate(base_metadata) |
986 | 986 |
|
987 | 987 | with pytest.raises(CommitFailedException, match="Requirement failed: current table metadata is missing"): |
988 | | - AssertRefSnapshotId(ref="main", snapshot_id=1).validate(None) |
| 988 | + AssertRefSnapshotId(ref=MAIN_BRANCH, snapshot_id=1).validate(None) |
989 | 989 |
|
990 | 990 | with pytest.raises( |
991 | 991 | CommitFailedException, |
992 | | - match="Requirement failed: branch main was created concurrently", |
| 992 | + match=f"Requirement failed: branch {MAIN_BRANCH} was created concurrently", |
993 | 993 | ): |
994 | | - AssertRefSnapshotId(ref="main", snapshot_id=None).validate(base_metadata) |
| 994 | + AssertRefSnapshotId(ref=MAIN_BRANCH, snapshot_id=None).validate(base_metadata) |
995 | 995 |
|
996 | 996 | with pytest.raises( |
997 | 997 | CommitFailedException, |
998 | | - match="Requirement failed: branch main has changed: expected id 1, found 3055729675574597004", |
| 998 | + match=f"Requirement failed: branch {MAIN_BRANCH} has changed: expected id 1, found 3055729675574597004", |
999 | 999 | ): |
1000 | | - AssertRefSnapshotId(ref="main", snapshot_id=1).validate(base_metadata) |
| 1000 | + AssertRefSnapshotId(ref=MAIN_BRANCH, snapshot_id=1).validate(base_metadata) |
1001 | 1001 |
|
1002 | | - with pytest.raises( |
1003 | | - CommitFailedException, |
1004 | | - match="Requirement failed: branch or tag not_exist_branch is missing, expected 1", |
1005 | | - ): |
1006 | | - AssertRefSnapshotId(ref="not_exist_branch", snapshot_id=1).validate(base_metadata) |
| 1002 | + non_existing_ref = "not_exist_branch_or_tag" |
| 1003 | + assert table_v2.refs().get("not_exist_branch_or_tag") is None |
1007 | 1004 |
|
1008 | 1005 | with pytest.raises( |
1009 | 1006 | CommitFailedException, |
1010 | | - match="Requirement failed: branch or tag not_exist_tag is missing, expected 1", |
| 1007 | + match=f"Requirement failed: branch or tag {non_existing_ref} is missing, expected 1", |
1011 | 1008 | ): |
1012 | | - AssertRefSnapshotId(ref="not_exist_tag", snapshot_id=1).validate(base_metadata) |
| 1009 | + AssertRefSnapshotId(ref=non_existing_ref, snapshot_id=1).validate(base_metadata) |
1013 | 1010 |
|
1014 | 1011 | # existing Tag in metadata: test |
1015 | 1012 | ref_tag = table_v2.refs().get("test") |
|
0 commit comments