vinjai commented on code in PR #941: URL: https://github.com/apache/iceberg-python/pull/941#discussion_r1865177262
########## tests/table/test_init.py: ########## @@ -982,28 +982,43 @@ def test_assert_table_uuid(table_v2: Table) -> None: def test_assert_ref_snapshot_id(table_v2: Table) -> None: base_metadata = table_v2.metadata - AssertRefSnapshotId(ref="main", snapshot_id=base_metadata.current_snapshot_id).validate(base_metadata) + AssertRefSnapshotId(ref="main", snapshot_id=base_metadata.current_snapshot_id, ref_type=SnapshotRefType.BRANCH).validate( + base_metadata + ) with pytest.raises(CommitFailedException, match="Requirement failed: current table metadata is missing"): - AssertRefSnapshotId(ref="main", snapshot_id=1).validate(None) + AssertRefSnapshotId(ref="main", snapshot_id=1, ref_type=SnapshotRefType.BRANCH).validate(None) with pytest.raises( CommitFailedException, match="Requirement failed: branch main was created concurrently", ): - AssertRefSnapshotId(ref="main", snapshot_id=None).validate(base_metadata) + AssertRefSnapshotId(ref="main", snapshot_id=None, ref_type=SnapshotRefType.BRANCH).validate(base_metadata) with pytest.raises( CommitFailedException, match="Requirement failed: branch main has changed: expected id 1, found 3055729675574597004", ): - AssertRefSnapshotId(ref="main", snapshot_id=1).validate(base_metadata) + AssertRefSnapshotId(ref="main", snapshot_id=1, ref_type=SnapshotRefType.BRANCH).validate(base_metadata) + + with pytest.raises( + CommitFailedException, + match="Requirement failed: branch or tag not_exist_branch is missing, expected 1", + ): + AssertRefSnapshotId(ref="not_exist_branch", snapshot_id=1, ref_type=SnapshotRefType.BRANCH).validate(base_metadata) + + with pytest.raises( + CommitFailedException, + match="Requirement failed: branch or tag not_exist_tag is missing, expected 1", + ): + AssertRefSnapshotId(ref="not_exist_tag", snapshot_id=1, ref_type=SnapshotRefType.TAG).validate(base_metadata) Review Comment: Also, we currently don't support all scenarios for tags in pyiceberg such as: 1. Replace Tag 2. Delete Tag We should probably add issues for the same too ########## tests/table/test_init.py: ########## @@ -982,28 +982,43 @@ def test_assert_table_uuid(table_v2: Table) -> None: def test_assert_ref_snapshot_id(table_v2: Table) -> None: base_metadata = table_v2.metadata - AssertRefSnapshotId(ref="main", snapshot_id=base_metadata.current_snapshot_id).validate(base_metadata) + AssertRefSnapshotId(ref="main", snapshot_id=base_metadata.current_snapshot_id, ref_type=SnapshotRefType.BRANCH).validate( + base_metadata + ) with pytest.raises(CommitFailedException, match="Requirement failed: current table metadata is missing"): - AssertRefSnapshotId(ref="main", snapshot_id=1).validate(None) + AssertRefSnapshotId(ref="main", snapshot_id=1, ref_type=SnapshotRefType.BRANCH).validate(None) with pytest.raises( CommitFailedException, match="Requirement failed: branch main was created concurrently", ): - AssertRefSnapshotId(ref="main", snapshot_id=None).validate(base_metadata) + AssertRefSnapshotId(ref="main", snapshot_id=None, ref_type=SnapshotRefType.BRANCH).validate(base_metadata) with pytest.raises( CommitFailedException, match="Requirement failed: branch main has changed: expected id 1, found 3055729675574597004", ): - AssertRefSnapshotId(ref="main", snapshot_id=1).validate(base_metadata) + AssertRefSnapshotId(ref="main", snapshot_id=1, ref_type=SnapshotRefType.BRANCH).validate(base_metadata) + + with pytest.raises( + CommitFailedException, + match="Requirement failed: branch or tag not_exist_branch is missing, expected 1", + ): + AssertRefSnapshotId(ref="not_exist_branch", snapshot_id=1, ref_type=SnapshotRefType.BRANCH).validate(base_metadata) + + with pytest.raises( + CommitFailedException, + match="Requirement failed: branch or tag not_exist_tag is missing, expected 1", + ): + AssertRefSnapshotId(ref="not_exist_tag", snapshot_id=1, ref_type=SnapshotRefType.TAG).validate(base_metadata) Review Comment: Also, we currently don't support all scenarios for tags in pyiceberg such as: 1. Replace Tag 2. Delete Tag We should probably add new issues for the same too -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org