Skip to content

Commit

Permalink
Fix test failures on moto
Browse files Browse the repository at this point in the history
  • Loading branch information
katdom13 committed Jun 14, 2024
1 parent ed83be6 commit f166198
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions wagtail_storages/tests/base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from django.conf import settings

import boto3
from moto import mock_s3
from moto import mock_aws


@mock_s3
@mock_aws
class CreateBucket:
def setUp(self):
bucket_name = settings.AWS_STORAGE_BUCKET_NAME
Expand Down
4 changes: 2 additions & 2 deletions wagtail_storages/tests/test_protected_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from django.test import TestCase
from django.urls import reverse

from moto import mock_s3
from moto import mock_aws

from wagtail_storages.factories import CollectionViewRestrictionFactory, DocumentFactory
from wagtail_storages.tests.base import CreateBucket
from wagtail_storages.tests.utils import is_s3_object_is_public


@mock_s3
@mock_aws
class AmazonS3DocumentTests(CreateBucket, TestCase):
def check_s3_url(self, url):
return "s3.amazonaws.com" in url or "media.torchbox.com" in url
Expand Down
10 changes: 5 additions & 5 deletions wagtail_storages/tests/test_signal_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.test import TestCase, override_settings

import factory
from moto import mock_s3
from moto import mock_aws

from wagtail_storages.factories import (
CollectionFactory,
Expand Down Expand Up @@ -39,7 +39,7 @@ def test_skipping_s3_storage_decorator_with_s3_storage(self):
mock.assert_called_once()


@mock_s3
@mock_aws
class TestUpdateDocumentAclsWhenCollectionSaved(CreateBucket, TestCase):
@factory.django.mute_signals(post_save)
def test_s3_object_acl_set_to_public(self):
Expand All @@ -60,7 +60,7 @@ def test_s3_object_acl_set_to_private(self):
self.assertFalse(is_s3_object_is_public(document.file.file.obj))


@mock_s3
@mock_aws
class TestUpdateDocumentAclsWhenDocumentSaved(CreateBucket, TestCase):
@factory.django.mute_signals(post_save)
def test_s3_object_acl_set_to_public(self):
Expand All @@ -80,7 +80,7 @@ def test_s3_object_acl_set_to_private(self):
self.assertFalse(is_s3_object_is_public(document.file.file.obj))


@mock_s3
@mock_aws
class TestPurgeDocumentsWhenCollectionSavedWithRestrictions(CreateBucket, TestCase):
@override_settings(
WAGTAILFRONTENDCACHE={
Expand Down Expand Up @@ -135,7 +135,7 @@ def test_cache_not_purged_for_public_collection(self):
urlopen_mock.assert_not_called()


@mock_s3
@mock_aws
class TestPurgeDocumentFromCacheWhenSaved(CreateBucket, TestCase):
@override_settings(
WAGTAILFRONTENDCACHE={
Expand Down
4 changes: 2 additions & 2 deletions wagtail_storages/tests/test_wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from django.test import RequestFactory, TestCase, override_settings

from moto import mock_s3
from moto import mock_aws

from wagtail_storages.factories import CollectionViewRestrictionFactory, DocumentFactory
from wagtail_storages.tests.base import CreateBucket
from wagtail_storages.wagtail_hooks import serve_document_from_s3


@mock_s3
@mock_aws
class TestWagtailHooks(CreateBucket, TestCase):
@override_settings(
DEFAULT_FILE_STORAGE="django.core.files.storage.FileSystemStorage"
Expand Down

0 comments on commit f166198

Please sign in to comment.