|
@@ -2,11 +2,12 @@ import datetime
|
|
|
import json
|
|
|
import urllib
|
|
|
|
|
|
+from django.conf import settings
|
|
|
from django.contrib.auth.models import Group, Permission
|
|
|
from django.core.files.uploadedfile import SimpleUploadedFile, TemporaryUploadedFile
|
|
|
from django.template.defaultfilters import filesizeformat
|
|
|
from django.template.loader import render_to_string
|
|
|
-from django.test import RequestFactory, TestCase, TransactionTestCase
|
|
|
+from django.test import RequestFactory, TestCase, TransactionTestCase, override_settings
|
|
|
from django.urls import reverse
|
|
|
from django.utils.encoding import force_str
|
|
|
from django.utils.html import escape, escapejs
|
|
@@ -29,7 +30,7 @@ from wagtail.test.testapp.models import (
|
|
|
EventPage,
|
|
|
VariousOnDeleteModel,
|
|
|
)
|
|
|
-from wagtail.test.utils import WagtailTestUtils, override_settings
|
|
|
+from wagtail.test.utils import WagtailTestUtils
|
|
|
|
|
|
from .utils import Image, get_test_image_file, get_test_image_file_svg
|
|
|
|
|
@@ -632,7 +633,12 @@ class TestImageAddView(WagtailTestUtils, TestCase):
|
|
|
self.assertEqual(image.collection, root_collection)
|
|
|
|
|
|
@override_settings(
|
|
|
- DEFAULT_FILE_STORAGE="wagtail.test.dummy_external_storage.DummyExternalStorage"
|
|
|
+ STORAGES={
|
|
|
+ **settings.STORAGES,
|
|
|
+ "default": {
|
|
|
+ "BACKEND": "wagtail.test.dummy_external_storage.DummyExternalStorage"
|
|
|
+ },
|
|
|
+ },
|
|
|
)
|
|
|
def test_add_with_external_file_storage(self):
|
|
|
response = self.post(
|
|
@@ -940,7 +946,12 @@ class TestImageEditView(WagtailTestUtils, TestCase):
|
|
|
self.assertContains(response, expected_url)
|
|
|
|
|
|
@override_settings(
|
|
|
- DEFAULT_FILE_STORAGE="wagtail.test.dummy_external_storage.DummyExternalStorage"
|
|
|
+ STORAGES={
|
|
|
+ **settings.STORAGES,
|
|
|
+ "default": {
|
|
|
+ "BACKEND": "wagtail.test.dummy_external_storage.DummyExternalStorage"
|
|
|
+ },
|
|
|
+ },
|
|
|
)
|
|
|
def test_simple_with_external_storage(self):
|
|
|
# The view calls get_file_size on the image that closes the file if
|
|
@@ -1040,7 +1051,12 @@ class TestImageEditView(WagtailTestUtils, TestCase):
|
|
|
self.assertNotEqual(self.image.file_hash, "abcedf")
|
|
|
|
|
|
@override_settings(
|
|
|
- DEFAULT_FILE_STORAGE="wagtail.test.dummy_external_storage.DummyExternalStorage"
|
|
|
+ STORAGES={
|
|
|
+ **settings.STORAGES,
|
|
|
+ "default": {
|
|
|
+ "BACKEND": "wagtail.test.dummy_external_storage.DummyExternalStorage"
|
|
|
+ },
|
|
|
+ },
|
|
|
)
|
|
|
def test_edit_with_new_image_file_and_external_storage(self):
|
|
|
file_content = get_test_image_file().file.getvalue()
|
|
@@ -1085,7 +1101,12 @@ class TestImageEditView(WagtailTestUtils, TestCase):
|
|
|
self.check_get_missing_file_displays_warning()
|
|
|
|
|
|
@override_settings(
|
|
|
- DEFAULT_FILE_STORAGE="wagtail.test.dummy_external_storage.DummyExternalStorage"
|
|
|
+ STORAGES={
|
|
|
+ **settings.STORAGES,
|
|
|
+ "default": {
|
|
|
+ "BACKEND": "wagtail.test.dummy_external_storage.DummyExternalStorage"
|
|
|
+ },
|
|
|
+ },
|
|
|
)
|
|
|
def test_get_missing_file_displays_warning_with_custom_storage(self):
|
|
|
self.check_get_missing_file_displays_warning()
|
|
@@ -2097,7 +2118,12 @@ class TestImageChooserUploadView(WagtailTestUtils, TestCase):
|
|
|
self.assertContains(response, expected_action_attr)
|
|
|
|
|
|
@override_settings(
|
|
|
- DEFAULT_FILE_STORAGE="wagtail.test.dummy_external_storage.DummyExternalStorage"
|
|
|
+ STORAGES={
|
|
|
+ **settings.STORAGES,
|
|
|
+ "default": {
|
|
|
+ "BACKEND": "wagtail.test.dummy_external_storage.DummyExternalStorage"
|
|
|
+ },
|
|
|
+ },
|
|
|
)
|
|
|
def test_upload_with_external_storage(self):
|
|
|
response = self.client.post(
|