"""Tests for font folder structure: required subdirs and at least one font file per font.""" import pytest from tests.conftest import FONT_FILES_DIR, REQUIRED_SUBDIRS, WEB_EXTENSIONS, get_font_dir_names # Top-level names to ignore (e.g. .DS_Store; cleanup script removes these) IGNORED_TOPLEVEL = {".DS_Store"} @pytest.mark.parametrize("font_name", get_font_dir_names()) def test_font_has_required_subdirs_only(font_name): """Each font folder has exactly ttf/, otf/, web/, other_files/ and no other top-level items (except ignored).""" font_dir = FONT_FILES_DIR / font_name assert font_dir.is_dir(), f"Font dir missing: {font_dir}" names = [p.name for p in font_dir.iterdir() if p.name not in IGNORED_TOPLEVEL] for required in REQUIRED_SUBDIRS: assert required in names, f"{font_name}: missing subdir {required}/" # All must be directories (the four subdirs) for name in names: assert (font_dir / name).is_dir(), f"{font_name}: unexpected file or non-dir at top level: {name}" assert len(names) == 4, f"{font_name}: expected exactly 4 subdirs, got {names}" @pytest.mark.parametrize("font_name", get_font_dir_names()) def test_font_has_at_least_one_font_file_or_other(font_name): """Each font folder has at least one font file (ttf/otf/web) or content in other_files.""" font_dir = FONT_FILES_DIR / font_name has_ttf = any((font_dir / "ttf").glob("*.ttf")) has_otf = any((font_dir / "otf").glob("*.otf")) web_dir = font_dir / "web" has_web = any( f.suffix.lower() in WEB_EXTENSIONS for f in web_dir.glob("*") if f.is_file() ) other_dir = font_dir / "other_files" has_other = any(other_dir.iterdir()) if other_dir.exists() else False assert has_ttf or has_otf or has_web or has_other, ( f"{font_name}: no font files in ttf/, otf/, or web/ and no content in other_files/" )