"""Clips go to Videos/Summit/, the game named by `summit run` (SUMMIT_GAME).""" import sys sys.path.insert(0, str(__import__("pathlib").Path(__file__).resolve().parents[1])) from pathlib import Path from framegen import oslayer, replay def _folder(monkeypatch, game=None): monkeypatch.delenv("SMOOVPLAY_REPLAY_DIR", raising=False) monkeypatch.setattr(oslayer, "videos_dir", lambda: Path("/v")) if game is None: monkeypatch.delenv("SUMMIT_GAME", raising=False) else: monkeypatch.setenv("SUMMIT_GAME", game) return replay.videos_folder() def test_a_folder_per_game(monkeypatch): assert _folder(monkeypatch, "Portal 2") == Path("/v/Summit/Portal 2") def test_no_game_saves_in_summit(monkeypatch): assert _folder(monkeypatch) == Path("/v/Summit") assert _folder(monkeypatch, " ") == Path("/v/Summit") def test_names_are_made_safe(monkeypatch): assert _folder(monkeypatch, 'Half-Life: "Alyx"/VR?') == Path("/v/Summit/Half-Life Alyx VR") assert _folder(monkeypatch, "../..") == Path("/v/Summit") def test_override_still_wins(monkeypatch, tmp_path): monkeypatch.setenv("SMOOVPLAY_REPLAY_DIR", str(tmp_path)) monkeypatch.setenv("SUMMIT_GAME", "Portal 2") assert replay.videos_folder() == tmp_path def test_toast_path_uses_this_systems_separator(): import os p = Path("/home/u/Videos/Summit/Portal 2/Portal 2 2026-11-24 09-27-53.mp4") assert replay._short(p) == os.sep.join(("Summit", "Portal 2", "Portal 2 2026-11-24 09-27-53.mp4"))