""" V8.2.1: pytest-Fixtures für saubere Pfad-Tests. Statt nested patches in jedem Test wird der room-map.json Pfad pro Test umgebogen. Verwendet tempfile.TemporaryDirectory für Isolation. """ import json import tempfile from pathlib import Path import pytest @pytest.fixture def temp_room_map_path(): """Erzeugt eine temporäre room-map.json mit minimalem Test-Setup. Returns: Path: Pfad zur temporären room-map.json. """ tmp = tempfile.TemporaryDirectory() map_path = Path(tmp.name) / "room-map.json" test_data = { "version": 2, "rooms": { "catchall_id": { "name": "#CatchAll", "theme": "Catch-all room", "keywords_100": [], "keywords_context": [], "catch_all": True, }, "plugin_room_id": { "name": "#Rocketchat-Plugin", "theme": "Plugin-Entwicklung", "keywords_100": ["plugin"], "keywords_context": ["adapter"], "catch_all": False, }, }, "excluded_rooms": [], "fact_store_path": str(Path(tmp.name) / "docs"), } with open(map_path, "w") as f: json.dump(test_data, f) yield map_path tmp.cleanup() @pytest.fixture def temp_state_path(): """Erzeugt einen temporären Pfad für archivar_state.json. Returns: str: Pfad zur temporären State-Datei. """ tmp = tempfile.TemporaryDirectory() state_path = str(Path(tmp.name) / "archivar_state.json") yield state_path tmp.cleanup()