import asyncio import os import sys from pathlib import Path sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) import config def _reset_config_path(tmp_path: Path): config.CONFIG_PATH = tmp_path / "config.json" def test_retry_state_round_trip(tmp_path): async def run(): _reset_config_path(tmp_path) await config.set_retry_state( guild_id=123, file_path="recordings/123/session/meeting.wav", source_channel_id=456, reason="transcription failed", ) return await config.get_retry_state(123) state = asyncio.run(run()) assert state == { "file_path": "recordings/123/session/meeting.wav", "source_channel_id": 456, "reason": "transcription failed", } def test_clear_retry_state_removes_saved_entry(tmp_path): async def run(): _reset_config_path(tmp_path) await config.set_retry_state(123, "a.wav", 456, "oops") await config.clear_retry_state(123) return await config.get_retry_state(123) assert asyncio.run(run()) is None