Skip to content

Commit 182e90b

Browse files
committed
async static files panel test
1 parent d5bdcc3 commit 182e90b

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

tests/panels/test_staticfiles.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from django.conf import settings
22
from django.contrib.staticfiles import finders
3+
from django.shortcuts import render
4+
from django.test import AsyncRequestFactory
35

46
from ..base import BaseTestCase
57

@@ -27,6 +29,17 @@ def test_default_case(self):
2729
self.panel.get_staticfiles_dirs(), finders.FileSystemFinder().locations
2830
)
2931

32+
async def test_store_staticfiles_with_async_context(self):
33+
async def get_response(request):
34+
# template contains one static file
35+
return render(request, "staticfiles/async_static.html")
36+
37+
self._get_response = get_response
38+
async_request = AsyncRequestFactory().get("/")
39+
response = await self.panel.process_request(async_request)
40+
self.panel.generate_stats(self.request, response)
41+
self.assertNotEqual(self.panel.num_used, 0)
42+
3043
def test_insert_content(self):
3144
"""
3245
Test that the panel only inserts content after generate_stats and

tests/templates/base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html>
33
<head>
44
<title>{{ title }}</title>
5+
{% block head %}{% endblock %}
56
</head>
67
<body>
78
{% block content %}{% endblock %}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% extends "base.html" %}
2+
{% load static %}
3+
4+
{% block head %}
5+
<link rel="stylesheet" href="{% static 'additional_static/base.css' %}">
6+
{% endblock %}

0 commit comments

Comments
 (0)