From 5ae5dd30e2181478ad14a0da81b4cc041b451843 Mon Sep 17 00:00:00 2001 From: Dan Braghis Date: Thu, 4 Jun 2015 22:15:01 +0100 Subject: [PATCH 1/2] Remove django-sendfile from requirements and test settings --- requirements-dev.txt | 1 - wagtail/tests/settings.py | 3 --- 2 files changed, 4 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 0a7e6c66e..8b5545646 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,7 +3,6 @@ mock>=1.0.0 python-dateutil>=2.2 pytz>=2014.7 Pillow>=2.7.0 -django-sendfile==0.3.6 # For coverage and PEP8 linting coverage>=3.7.0 diff --git a/wagtail/tests/settings.py b/wagtail/tests/settings.py index 88f7eb235..580d3c4fa 100644 --- a/wagtail/tests/settings.py +++ b/wagtail/tests/settings.py @@ -83,7 +83,6 @@ INSTALLED_APPS = ( 'taggit', 'compressor', - 'sendfile', 'wagtail.wagtailcore', 'wagtail.wagtailadmin', @@ -114,8 +113,6 @@ INSTALLED_APPS = ( ) - - # Using DatabaseCache to make sure that the cache is cleared between tests. # This prevents false-positives in some wagtail core tests where we are # changing the 'wagtail_root_paths' key which may cause future tests to fail. From 065084a210c680b9e07580809e2aa099d8884291 Mon Sep 17 00:00:00 2001 From: Dan Braghis Date: Thu, 4 Jun 2015 22:15:58 +0100 Subject: [PATCH 2/2] Add sendfile TestCase that can be skipped if sendfile not installed --- wagtail/wagtaildocs/tests.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/wagtail/wagtaildocs/tests.py b/wagtail/wagtaildocs/tests.py index f5bdf58b2..6e69c4f1f 100644 --- a/wagtail/wagtaildocs/tests.py +++ b/wagtail/wagtaildocs/tests.py @@ -591,6 +591,26 @@ class TestServeView(TestCase): from wagtail.utils.sendfile import _get_sendfile _get_sendfile.clear() + +class TestServeViewWithSendfile(TestCase): + def setUp(self): + # Import using a try-catch block to prevent crashes if the + # django-sendfile module is not installed + try: + import sendfile # noqa + except ImportError: + raise unittest.SkipTest("django-sendfile not installed") + + self.document = models.Document(title="Test document") + self.document.file.save('example.doc', ContentFile("A boring example document")) + + def get(self): + return self.client.get(reverse('wagtaildocs_serve', args=(self.document.id, 'example.doc'))) + + def clear_sendfile_cache(self): + from wagtail.utils.sendfile import _get_sendfile + _get_sendfile.clear() + @override_settings(SENDFILE_BACKEND='sendfile.backends.xsendfile') def test_sendfile_xsendfile_backend(self): self.clear_sendfile_cache()