1515# specific language governing permissions and limitations
1616# under the License.
1717from typing import cast
18+
1819import pytest
20+
1921from pyiceberg .catalog import Catalog
2022from pyiceberg .manifest import (
2123 DataFile ,
@@ -93,20 +95,20 @@ def test_replace_internally(catalog: Catalog) -> None:
9395 # 1. Has a unique snapshot ID
9496 assert snapshot .snapshot_id is not None
9597 assert snapshot .snapshot_id != old_snapshot_id
96-
98+
9799 # 2. Parent points to the previous snapshot
98100 assert snapshot .parent_snapshot_id == old_snapshot_id
99-
101+
100102 # 3. Sequence number is exactly previous + 1
101103 assert snapshot .sequence_number == old_sequence_number + 1
102-
104+
103105 # 4. Operation type is set to "replace"
104106 assert summary ["operation" ] == Operation .REPLACE
105-
107+
106108 # 5. Manifest list path is correct (just verify it exists and is a string path)
107109 assert snapshot .manifest_list is not None
108110 assert isinstance (snapshot .manifest_list , str )
109-
111+
110112 # 6. Summary counts are accurate
111113 assert summary ["added-data-files" ] == "1"
112114 assert summary ["deleted-data-files" ] == "1"
@@ -122,7 +124,7 @@ def test_replace_internally(catalog: Catalog) -> None:
122124
123125 # We expect 3 entries: ADDED, DELETED, and EXISTING
124126 assert len (entries ) == 3
125-
127+
126128 # Check ADDED
127129 added_entries = [e for e in entries if e .status == ManifestEntryStatus .ADDED ]
128130 assert len (added_entries ) == 1
@@ -216,15 +218,15 @@ def test_replace_reuses_unaffected_manifests(catalog: Catalog) -> None:
216218 snapshot_after = cast (Snapshot , table .current_snapshot ())
217219 assert snapshot_after is not None
218220 manifests_after = snapshot_after .manifests (table .io )
219-
220- # We expect 3 manifests:
221+
222+ # We expect 3 manifests:
221223 # 1. The reused one for file B
222224 # 2. The newly rewritten one marking file A as DELETED
223225 # 3. The new one for file C (ADDED)
224226 assert len (manifests_after ) == 3
225-
227+
226228 manifest_paths_after = [m .manifest_path for m in manifests_after ]
227-
229+
228230 # ASSERTION 1: The untouched manifest is completely reused (the path matches exactly)
229231 assert manifest_b_path in manifest_paths_after
230232
@@ -309,7 +311,7 @@ def test_replace_invariant_violation(catalog: Catalog) -> None:
309311 file_path = "s3://bucket/test/data/too_many.parquet" ,
310312 file_format = FileFormat .PARQUET ,
311313 partition = Record (),
312- record_count = 101 ,
314+ record_count = 101 ,
313315 file_size_in_bytes = 1024 ,
314316 content = DataFileContent .DATA ,
315317 )
@@ -352,7 +354,7 @@ def test_replace_allows_shrinking_for_soft_deletes(catalog: Catalog) -> None:
352354 file_path = "s3://bucket/test/data/shrunk.parquet" ,
353355 file_format = FileFormat .PARQUET ,
354356 partition = Record (),
355- record_count = 90 ,
357+ record_count = 90 ,
356358 file_size_in_bytes = 900 ,
357359 content = DataFileContent .DATA ,
358360 )
@@ -436,7 +438,7 @@ def test_replace_passes_through_delete_manifests(catalog: Catalog) -> None:
436438 for m in manifests_before :
437439 if m .content == ManifestContent .DELETES :
438440 delete_manifest_path = m .manifest_path
439-
441+
440442 assert delete_manifest_path is not None
441443
442444 # Commit 3: Replace data file A with data file B
@@ -451,4 +453,4 @@ def test_replace_passes_through_delete_manifests(catalog: Catalog) -> None:
451453 manifests_after = snapshot_after .manifests (table .io )
452454 manifest_paths_after = [m .manifest_path for m in manifests_after ]
453455
454- assert delete_manifest_path in manifest_paths_after
456+ assert delete_manifest_path in manifest_paths_after
0 commit comments