from __future__ import annotations from errors import IncrementalError from increment.paths import parse_index_path, parse_schema_path from tests.pytest_compat import pytest def test_rejects_dispatcher_index_when_table_across_nodes_disabled(): with pytest.raises(IncrementalError, match="table-across-nodes"): parse_index_path( "increment/test/worker/120/2026-05-25/meta/CDC_dispatcher01.index", "increment/", "CDC_dispatcher01_000001.csv\n", ) def test_increment_paths_decode_normalized_source_path_segments(): schema_path = parse_schema_path( "increment/test%20tenant/worker%20part/meta/schema_120_1.json", "increment", ) index_path = parse_index_path( "increment/test%20tenant/worker%20part/120/2026-05-25/meta/CDC.index", "increment", "CDC000001.csv\n", ) assert schema_path is not None assert schema_path.source_schema == "test tenant" assert schema_path.source_table == "worker part" assert index_path is not None assert index_path.source_schema == "test tenant" assert index_path.source_table == "worker part" assert index_path.data_file_key(1) == "increment/test%20tenant/worker%20part/120/2026-05-25/CDC000001.csv" def test_increment_paths_reject_decoded_path_separator(): with pytest.raises(IncrementalError, match="invalid incremental object path segment"): parse_schema_path( "increment/test%2Ftenant/worker/meta/schema_120_1.json", "increment", ) with pytest.raises(IncrementalError, match="invalid incremental object path segment"): parse_index_path( "increment/test/worker%2Fpart/120/2026-05-25/meta/CDC.index", "increment", "CDC000001.csv\n", )