UPRN-prefixed property folders rename to a single-UPRN filename 🟥

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-03 12:09:02 +00:00
parent 781251eb07
commit 787f7731b2

View file

@ -124,6 +124,33 @@ def test_run_renames_files_for_property_under_batch_root(tmp_path: Path) -> None
sp.rename_file.assert_called_once_with("id-1", "100_1 High St AB1 2CD_Survey.pdf")
def test_run_uprn_prefixed_address_yields_single_uprn_filename(
tmp_path: Path,
) -> None:
# Arrange
csv_path = _write_csv(tmp_path, [("100", "100_1 High St", "AB1 2CD")])
batch_assessment = _assessment_path(
f"{BASE_PATH}/_Sero Batch 2", "100_1 High St", "AB1 2CD"
)
sp = MagicMock()
def fake_get(path: str) -> dict[str, Any]:
if path == BASE_PATH:
return {"value": [_make_folder("_Sero Batch 2")]}
if path == batch_assessment:
return {"value": [_make_file("Survey.pdf", "id-1")]}
raise ValueError("not found")
sp.get_folders_in_path.side_effect = fake_get
# Act
SharepointRenamerOrchestrator(sp, csv_path).run()
# Assert
sp.rename_file.assert_called_once_with("id-1", "100_1 High St AB1 2CD_Survey.pdf")
# ---------------------------------------------------------------------------
# _process_folder — files only at root level
# ---------------------------------------------------------------------------