import os from src.decode import party_memory from src.utils import platform_utils def test_party_memory_save_load_and_clear(monkeypatch, tmp_path): monkeypatch.setattr(platform_utils, 'config_dir', lambda: str(tmp_path)) party_memory.save_last_party([ 'bionicKatana', 'fatbrick', 'fatbrick', '', None]) assert party_memory.load_last_party() == ['bionicKatana', 'fatbrick'] assert os.path.isfile(tmp_path / 'last-party.json') party_memory.clear_last_party() assert party_memory.load_last_party() == [] assert not os.path.exists(tmp_path / 'last-party.json') def test_party_memory_ignores_corrupt_file(monkeypatch, tmp_path): monkeypatch.setattr(platform_utils, 'config_dir', lambda: str(tmp_path)) path = tmp_path / 'last-party.json' path.write_text('{not json') assert party_memory.load_last_party() == []