mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Renamer warns once per property only after all roots miss 🟥
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
1196a8f75d
commit
ce749061aa
1 changed files with 35 additions and 3 deletions
|
|
@ -198,14 +198,46 @@ def test_ignores_package_items() -> None:
|
|||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_missing_folder_logs_warning_and_returns(caplog: pytest.LogCaptureFixture) -> None:
|
||||
def test_missing_folder_returns_false_without_warning(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
# Arrange
|
||||
sp = MagicMock()
|
||||
sp.get_folders_in_path.side_effect = ValueError("not found")
|
||||
|
||||
_make_orchestrator(sp)._process_folder("missing/path", "400", "4 Elm St", "AA2 2BB")
|
||||
# Act
|
||||
found = _make_orchestrator(sp)._process_folder(
|
||||
"missing/path", "400", "4 Elm St", "AA2 2BB"
|
||||
)
|
||||
|
||||
# Assert
|
||||
assert found is False
|
||||
sp.rename_file.assert_not_called()
|
||||
assert any("Missing folder" in r.message and "400" in r.message for r in caplog.records)
|
||||
assert not any("Missing folder" in r.message for r in caplog.records)
|
||||
|
||||
|
||||
def test_run_warns_once_when_property_missing_from_all_roots(
|
||||
tmp_path: Path, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
# Arrange
|
||||
csv_path = _write_csv(tmp_path, [("400", "4 Elm St", "AA2 2BB")])
|
||||
sp = MagicMock()
|
||||
|
||||
def fake_get(path: str) -> dict[str, Any]:
|
||||
if path == BASE_PATH:
|
||||
return {"value": [_make_folder("_Sero Batch 2")]}
|
||||
raise ValueError("not found")
|
||||
|
||||
sp.get_folders_in_path.side_effect = fake_get
|
||||
|
||||
# Act
|
||||
SharepointRenamerOrchestrator(sp, csv_path).run()
|
||||
|
||||
# Assert
|
||||
sp.rename_file.assert_not_called()
|
||||
warnings = [r for r in caplog.records if "Missing folder" in r.message]
|
||||
assert len(warnings) == 1
|
||||
assert "400" in warnings[0].message
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue