diff --git a/orchestration/sharepoint_renamer_orchestrator.py b/orchestration/sharepoint_renamer_orchestrator.py index 42b0e803c..15917f0a2 100644 --- a/orchestration/sharepoint_renamer_orchestrator.py +++ b/orchestration/sharepoint_renamer_orchestrator.py @@ -11,6 +11,7 @@ BASE_PATH = ( "Sero Project Documents/Property Folders" ) ASSESSMENT_SUBFOLDER = "A. Assessment" +BATCH_FOLDER_PREFIX = "_Sero Batch" logger = setup_logger() @@ -65,6 +66,9 @@ class SharepointRenamerOrchestrator: self._csv_path = csv_path self._dry_run = dry_run + def _discover_roots(self) -> list[str]: + raise NotImplementedError + def run(self) -> None: with open(self._csv_path, newline="", encoding="utf-8-sig") as f: reader = csv.DictReader(f) diff --git a/tests/scripts/test_rename_sharepoint_files.py b/tests/scripts/test_rename_sharepoint_files.py index 5affea7e2..35c4edc3e 100644 --- a/tests/scripts/test_rename_sharepoint_files.py +++ b/tests/scripts/test_rename_sharepoint_files.py @@ -4,6 +4,7 @@ from unittest.mock import MagicMock import pytest from orchestration.sharepoint_renamer_orchestrator import ( + BASE_PATH, SharepointRenamerOrchestrator, build_canonical_filename, ) @@ -47,6 +48,35 @@ def test_no_prefix_still_canonical() -> None: assert result == "100_1 High St AB1 2CD_Survey.pdf" +# --------------------------------------------------------------------------- +# _discover_roots — batch subfolders become extra roots +# --------------------------------------------------------------------------- + + +def test_discover_roots_includes_sero_batch_folders() -> None: + # Arrange + sp = MagicMock() + sp.get_folders_in_path.return_value = { + "value": [ + _make_folder("1 High St, AB1 2CD"), + _make_folder("_Sero Batch 3"), + _make_folder("_Sero Batch 2"), + _make_file("stray.pdf"), + ] + } + + # Act + roots = _make_orchestrator(sp)._discover_roots() + + # Assert + assert roots == [ + BASE_PATH, + f"{BASE_PATH}/_Sero Batch 2", + f"{BASE_PATH}/_Sero Batch 3", + ] + sp.get_folders_in_path.assert_called_once_with(BASE_PATH) + + # --------------------------------------------------------------------------- # _process_folder — files only at root level # ---------------------------------------------------------------------------