From 268652505aa7e34a87e82e77f2397fd154161899 Mon Sep 17 00:00:00 2001 From: Egor Deev Date: Fri, 2 Oct 2026 12:10:57 +0000 Subject: [PATCH] =?UTF-8?q?=C2=AB=D0=9E=D0=B1=D0=BE=20=D0=BC=D0=BD=D0=B5?= =?UTF-8?q?=C2=BB:=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B5=D1=81=D1=83=D1=89=D0=B5=D1=81=D1=82=D0=B2?= =?UTF-8?q?=D1=83=D1=8E=D1=89=D1=83=D1=8E=20=D0=BA=D0=B0=D1=80=D1=82=D0=B8?= =?UTF-8?q?=D0=BD=D0=BA=D1=83-=D0=B7=D0=B0=D0=B3=D0=BB=D1=83=D1=88=D0=BA?= =?UTF-8?q?=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Без загруженного фото владельца страница падала с 500 (в манифесте статики нет images/hero.png). Теперь используется static/img/hero.jpg; добавлен тест, который проверяет, что все {% static %} в шаблонах указывают на существующие файлы. --- main/tests/test_pages.py | 17 +++++++++++++++++ templates/about.html | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/main/tests/test_pages.py b/main/tests/test_pages.py index 659085d..748c941 100644 --- a/main/tests/test_pages.py +++ b/main/tests/test_pages.py @@ -44,3 +44,20 @@ def test_visitor_cookie_is_signed_and_httponly(client): @pytest.mark.django_db def test_unknown_page_returns_404(client): assert client.get('/no-such-page/', HTTP_USER_AGENT=UA).status_code == 404 + + +def test_all_static_references_exist(): + """Каждый {% static %} в шаблонах указывает на существующий файл (иначе 500 в бою).""" + import re + from pathlib import Path + + from django.conf import settings + + pattern = re.compile(r"{% static '([^']+)' %}") + missing = [ + f'{tpl.name}: {ref}' + for tpl in Path(settings.BASE_DIR, 'templates').rglob('*.html') + for ref in pattern.findall(tpl.read_text(encoding='utf-8')) + if not Path(settings.BASE_DIR, 'static', ref).exists() + ] + assert not missing diff --git a/templates/about.html b/templates/about.html index 7f5fbf6..ebe82df 100644 --- a/templates/about.html +++ b/templates/about.html @@ -23,7 +23,7 @@ {% if site_settings.owner_photo %} {{ site_settings.owner_name }} {% else %} - {{ site_settings.owner_name }} + {{ site_settings.owner_name }} {% endif %}