Skip to content

Commit d7cee84

Browse files
committed
fix test error
1 parent a1891d5 commit d7cee84

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/integration/test_snapshot_operations.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from pyiceberg.catalog import Catalog
2020
from pyiceberg.table.refs import SnapshotRef
21+
from pyiceberg.table.snapshots import ancestors_of
2122

2223

2324
@pytest.mark.integration
@@ -54,7 +55,7 @@ def test_manage_snapshots_context_manager(catalog: Catalog) -> None:
5455
ms.create_tag(snapshot_id=current_snapshot_id, tag_name="testing")
5556
ms.set_current_snapshot(snapshot_id=expected_snapshot_id)
5657
ms.create_branch(snapshot_id=expected_snapshot_id, branch_name="testing2")
57-
assert tbl.current_snapshot().snapshot_id is not current_snapshot_id # type: ignore
58+
assert tbl.current_snapshot().snapshot_id != current_snapshot_id # type: ignore
5859
assert tbl.metadata.refs["testing"].snapshot_id == current_snapshot_id
5960
assert tbl.metadata.refs["main"] == SnapshotRef(snapshot_id=expected_snapshot_id, snapshot_ref_type="branch")
6061
assert tbl.metadata.refs["testing2"].snapshot_id == expected_snapshot_id
@@ -69,7 +70,7 @@ def test_rollback_to_snapshot(catalog: Catalog) -> None:
6970
rollback_snapshot_id = tbl.current_snapshot().parent_snapshot_id # type: ignore
7071
current_snapshot_id = tbl.current_snapshot().snapshot_id # type: ignore
7172
tbl.manage_snapshots().rollback_to_snapshot(snapshot_id=rollback_snapshot_id).commit() # type: ignore
72-
assert tbl.current_snapshot().snapshot_id is not current_snapshot_id # type: ignore
73+
assert tbl.current_snapshot().snapshot_id != current_snapshot_id # type: ignore
7374
assert tbl.metadata.refs["main"] == SnapshotRef(snapshot_id=rollback_snapshot_id, snapshot_ref_type="branch")
7475

7576

@@ -79,11 +80,11 @@ def test_rollback_to_timestamp(catalog: Catalog) -> None:
7980
identifier = "default.test_table_rollback_to_snapshot_id"
8081
tbl = catalog.load_table(identifier)
8182
assert len(tbl.history()) > 4
82-
current_snapshot_id, timestamp = tbl.history()[-1].snapshot_id, tbl.history()[-1].timestamp_ms
83-
expected_snapshot_id = tbl.snapshot_by_id(current_snapshot_id).parent_snapshot_id # type: ignore
83+
ancestors = list(ancestor for ancestor in ancestors_of(tbl.current_snapshot(), tbl.metadata)) # noqa
84+
ancestor_to_rollback_to = ancestors[-1]
85+
expected_snapshot_id, timestamp = ancestor_to_rollback_to.snapshot_id, ancestor_to_rollback_to.timestamp_ms + 1
8486
# not inclusive of rollback_timestamp
8587
tbl.manage_snapshots().rollback_to_timestamp(timestamp=timestamp).commit()
86-
assert tbl.current_snapshot().snapshot_id is not current_snapshot_id # type: ignore
8788
assert tbl.metadata.refs["main"] == SnapshotRef(snapshot_id=expected_snapshot_id, snapshot_ref_type="branch")
8889

8990

@@ -96,7 +97,7 @@ def test_set_current_snapshot_with_snapshot_id(catalog: Catalog) -> None:
9697
current_snapshot_id = tbl.current_snapshot().snapshot_id # type: ignore
9798
expected_snapshot_id = tbl.history()[-3].snapshot_id
9899
tbl.manage_snapshots().set_current_snapshot(snapshot_id=expected_snapshot_id).commit()
99-
assert tbl.current_snapshot().snapshot_id is not current_snapshot_id # type: ignore
100+
assert tbl.current_snapshot().snapshot_id != current_snapshot_id # type: ignore
100101
assert tbl.metadata.refs["main"] == SnapshotRef(snapshot_id=expected_snapshot_id, snapshot_ref_type="branch")
101102

102103

@@ -110,5 +111,5 @@ def test_set_current_snapshot_with_ref_name(catalog: Catalog) -> None:
110111
expected_snapshot_id = tbl.history()[-3].snapshot_id
111112
tbl.manage_snapshots().create_tag(snapshot_id=expected_snapshot_id, tag_name="test-tag").commit()
112113
tbl.manage_snapshots().set_current_snapshot(ref_name="test-tag").commit()
113-
assert tbl.current_snapshot().snapshot_id is not current_snapshot_id # type: ignore
114+
assert tbl.current_snapshot().snapshot_id != current_snapshot_id # type: ignore
114115
assert tbl.metadata.refs["main"] == SnapshotRef(snapshot_id=expected_snapshot_id, snapshot_ref_type="branch")

0 commit comments

Comments
 (0)