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 216081d commit 0d16104
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions yawn/management/tests/test_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ def test_webserver(mock_run):


def test_static_files():
app = webserver.get_wsgi_application()
whitenoise = webserver.DefaultFileServer(app, settings)
whitenoise.application = mock.Mock()

# 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(os.path.dirname(yawn.__file__), 'staticfiles', filename)
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()

# an API request
whitenoise({'PATH_INFO': '/api/'}, None)
assert whitenoise.application.call_count == 1
Expand Down

0 comments on commit 0d16104

Please sign in to comment.