import json from pathlib import Path import pytest from app.fonts import fonts,stylesheet def test_font_manifest_only_allows_explicit_local_paths(tmp_path,monkeypatch): monkeypatch.setenv('FONT_DIR',str(tmp_path)); (tmp_path/'test.woff2').write_bytes(b'font fixture') (tmp_path/'fonts.json').write_text(json.dumps({'Arial':[{'file':'test.woff2','weight':'bold','style':'italic'}]})) assert len(fonts())==1 and "font-weight:bold" in stylesheet() (tmp_path/'fonts.json').write_text(json.dumps({'Arial':'../outside.woff2'})) with pytest.raises(ValueError):fonts()