"""Tests for workshop_paths cache-resolution helpers.""" from pathlib import Path import pytest from l4d2web.services import workshop_paths def test_workshop_cache_root_uses_left4me_root(monkeypatch, tmp_path: Path) -> None: monkeypatch.setenv("LEFT4ME_ROOT", str(tmp_path)) assert workshop_paths.workshop_cache_root() == tmp_path / "workshop_cache" def test_cache_path_returns_id_only_filename(monkeypatch, tmp_path: Path) -> None: monkeypatch.setenv("LEFT4ME_ROOT", str(tmp_path)) assert workshop_paths.cache_path("12345") == tmp_path / "workshop_cache" / "12345.vpk" @pytest.mark.parametrize("bad", ["abc", "", "12/34", "..", "../etc", "1 2", " 1"]) def test_cache_path_rejects_non_digit_steam_id(monkeypatch, tmp_path: Path, bad: str) -> None: monkeypatch.setenv("LEFT4ME_ROOT", str(tmp_path)) with pytest.raises(ValueError): workshop_paths.cache_path(bad)