2828from pyiceberg .table .update .validate import validation_history
2929
3030
31- def test_validation_history (table_v2_with_extensive_snapshots : Table ) -> None :
32- """Test the validation history function."""
31+ @pytest .fixture
32+ def table_v2_with_extensive_snapshots_and_manifests (
33+ table_v2_with_extensive_snapshots : Table ,
34+ ) -> tuple [Table , dict [int , list [ManifestFile ]]]:
35+ """Fixture to create a table with extensive snapshots and manifests."""
3336 mock_manifests = {}
3437
3538 for i , snapshot in enumerate (table_v2_with_extensive_snapshots .snapshots ()):
@@ -46,10 +49,17 @@ def test_validation_history(table_v2_with_extensive_snapshots: Table) -> None:
4649 # Store the manifest for this specific snapshot
4750 mock_manifests [snapshot .snapshot_id ] = [mock_manifest ]
4851
49- expected_manifest_data_counts = len ([m for m in mock_manifests .values () if m [0 ].content == ManifestContent .DATA ]) - 1
52+ return table_v2_with_extensive_snapshots , mock_manifests
53+
54+
55+ def test_validation_history (table_v2_with_extensive_snapshots_and_manifests : tuple [Table , dict [int , list [ManifestFile ]]]) -> None :
56+ """Test the validation history function."""
57+ table , mock_manifests = table_v2_with_extensive_snapshots_and_manifests
58+
59+ expected_manifest_data_counts = len ([m for m in mock_manifests .values () if m [0 ].content == ManifestContent .DATA ])
5060
51- oldest_snapshot = table_v2_with_extensive_snapshots .snapshots ()[0 ]
52- newest_snapshot = cast (Snapshot , table_v2_with_extensive_snapshots .current_snapshot ())
61+ oldest_snapshot = table .snapshots ()[0 ]
62+ newest_snapshot = cast (Snapshot , table .current_snapshot ())
5363
5464 def mock_read_manifest_side_effect (self : Snapshot , io : FileIO ) -> list [ManifestFile ]:
5565 """Mock the manifests method to use the snapshot_id for lookup."""
@@ -60,7 +70,7 @@ def mock_read_manifest_side_effect(self: Snapshot, io: FileIO) -> list[ManifestF
6070
6171 with patch ("pyiceberg.table.snapshots.Snapshot.manifests" , new = mock_read_manifest_side_effect ):
6272 manifests , snapshots = validation_history (
63- table_v2_with_extensive_snapshots ,
73+ table ,
6474 newest_snapshot ,
6575 oldest_snapshot ,
6676 {Operation .APPEND },
@@ -80,7 +90,7 @@ def mock_read_manifest_side_effect(self: Snapshot, io: FileIO) -> list[ManifestF
8090 with patch ("pyiceberg.table.update.validate.ancestors_between" , return_value = [snapshot_with_no_summary ]):
8191 with pytest .raises (ValidationException ):
8292 validation_history (
83- table_v2_with_extensive_snapshots ,
93+ table ,
8494 newest_snapshot ,
8595 oldest_snapshot ,
8696 {Operation .APPEND },
0 commit comments