From 787f7731b23fb598ae87a3ecc5e1a32cf211220b Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Fri, 3 Jul 2026 12:09:02 +0000 Subject: [PATCH] =?UTF-8?q?UPRN-prefixed=20property=20folders=20rename=20t?= =?UTF-8?q?o=20a=20single-UPRN=20filename=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- tests/scripts/test_rename_sharepoint_files.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/scripts/test_rename_sharepoint_files.py b/tests/scripts/test_rename_sharepoint_files.py index b9d56562b..c732383c7 100644 --- a/tests/scripts/test_rename_sharepoint_files.py +++ b/tests/scripts/test_rename_sharepoint_files.py @@ -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 # ---------------------------------------------------------------------------