Files
state-corp-backend/tests/test_runtime_static.py
Aleksandr Meshchriakov b025f12856
All checks were successful
CI/CD Pipeline / Code Quality Checks (push) Successful in 4m32s
CI/CD Pipeline / Run Tests (push) Successful in 6m30s
CI/CD Pipeline / Build and Push Dev Images (push) Successful in 33s
CI/CD Pipeline / Deploy Dev via Compose (push) Successful in 31s
fix: serve collected static files with whitenoise
2026-07-16 15:42:35 +02:00

32 lines
1.1 KiB
Python

"""Regression checks for production static-file delivery."""
from pathlib import Path
from django.core.management import call_command
from django.test import Client, override_settings
from settings import base
def test_whitenoise_uses_compressed_manifest_storage():
assert (
base.STATICFILES_STORAGE
== "whitenoise.storage.CompressedManifestStaticFilesStorage"
)
def test_web_startup_collects_static_files_before_gunicorn():
script_path = Path(__file__).parents[1] / "docker" / "scripts" / "start-web.sh"
script = script_path.read_text(encoding="utf-8")
assert "python src/manage.py collectstatic --noinput" in script
assert script.index("collectstatic --noinput") < script.index("exec gunicorn")
def test_whitenoise_serves_collected_swagger_asset(tmp_path):
with override_settings(STATIC_ROOT=tmp_path):
call_command("collectstatic", interactive=False, verbosity=0)
response = Client().get("/static/drf-yasg/style.css")
assert response.status_code == 200
assert response["Content-Type"].startswith("text/css")