Skip to content

Commit cf5b061

Browse files
committed
first working tests (needs cleanup)
1 parent a39abd2 commit cf5b061

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

tests/table/test_validate.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
from unittest.mock import patch
2020

2121
from pyiceberg.io import FileIO
22-
from pyiceberg.manifest import ManifestContent, ManifestFile
22+
from pyiceberg.manifest import ManifestContent, ManifestEntry, ManifestEntryStatus, ManifestFile
2323
from pyiceberg.table import Table
24-
from pyiceberg.table.snapshots import Operation, Snapshot
24+
from pyiceberg.table.snapshots import Operation, Snapshot, Summary
2525
from pyiceberg.table.update.validate import deleted_data_files, validation_history
2626

2727

@@ -109,3 +109,34 @@ def mock_read_manifest_side_effect(self: Snapshot, io: FileIO) -> list[ManifestF
109109
)
110110

111111
assert result == []
112+
113+
# modify second to last snapshot to be a delete
114+
snapshots = table_v2_with_extensive_snapshots.snapshots()
115+
altered_snapshot = snapshots[-2]
116+
altered_snapshot = altered_snapshot.model_copy(update={"summary": Summary(operation=Operation.DELETE)})
117+
snapshots[-2] = altered_snapshot
118+
119+
table_v2_with_extensive_snapshots.metadata = table_v2_with_extensive_snapshots.metadata.model_copy(
120+
update={"snapshots": snapshots},
121+
)
122+
123+
my_entry = ManifestEntry(
124+
status=ManifestEntryStatus.DELETED,
125+
snapshot_id=altered_snapshot.snapshot_id,
126+
)
127+
128+
with (
129+
patch("pyiceberg.table.snapshots.Snapshot.manifests", new=mock_read_manifest_side_effect),
130+
patch("pyiceberg.manifest.ManifestFile.fetch_manifest_entry", return_value=[my_entry]),
131+
):
132+
result = list(
133+
deleted_data_files(
134+
table=table_v2_with_extensive_snapshots,
135+
starting_snapshot=newest_snapshot,
136+
data_filter=None,
137+
parent_snapshot=oldest_snapshot,
138+
partition_set=None,
139+
)
140+
)
141+
142+
assert result == [my_entry]

0 commit comments

Comments
 (0)