mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-13 01:33:16 +00:00
Merge pull request #1377 from zerolab/fix-sendfile-tests
Skip sendfile tests if django-sendfile is not installed. Fixes #1367
This commit is contained in:
commit
13725cbc44
3 changed files with 20 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue