Skip to content

Commit

Permalink
files for whitenoise
Browse files Browse the repository at this point in the history
  • Loading branch information
aclowes committed Aug 26, 2017
1 parent 0d16104 commit 3c7c8c4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
Empty file.
Empty file.
19 changes: 5 additions & 14 deletions yawn/management/tests/test_webserver.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import os
import sys
import subprocess

from unittest import mock

from django.conf import settings
from django.core import management

import yawn

from yawn.management.commands import webserver


Expand All @@ -21,17 +18,11 @@ def test_webserver(mock_run):


def test_static_files():
# make files to serve
root = os.path.join(os.path.dirname(yawn.__file__), 'staticfiles/')
os.makedirs(root, exist_ok=True)
for filename in ('index.html', 'favicon.ico'):
path = os.path.join(root, filename)
subprocess.check_call(['touch', path])

# setup whitenoise after the files exist
app = webserver.get_wsgi_application()
whitenoise = webserver.DefaultFileServer(app, settings)
whitenoise.application = mock.Mock()
root = os.path.join(settings.BASE_DIR, 'management/tests/static')
with mock.patch.object(settings, 'WHITENOISE_ROOT', root):
app = webserver.get_wsgi_application()
whitenoise = webserver.DefaultFileServer(app, settings)
whitenoise.application = mock.Mock()

# an API request
whitenoise({'PATH_INFO': '/api/'}, None)
Expand Down

0 comments on commit 3c7c8c4

Please sign in to comment.