From 0d1610414b62e934d9fe55e04b5638629e5fa31b Mon Sep 17 00:00:00 2001 From: Alec Clowes Date: Sat, 26 Aug 2017 10:14:50 -0700 Subject: [PATCH] files for whitenoise --- yawn/management/tests/test_webserver.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/yawn/management/tests/test_webserver.py b/yawn/management/tests/test_webserver.py index b199079..89415a9 100644 --- a/yawn/management/tests/test_webserver.py +++ b/yawn/management/tests/test_webserver.py @@ -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