Skip to content

Commit

Permalink
[MIG] storage_backend_s3: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Piernas Andrés committed Aug 9, 2023
1 parent 64708c0 commit 465cb1d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion storage_backend_s3/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Storage Backend S3",
"summary": "Implement amazon S3 Storage",
"version": "15.0.1.0.1",
"version": "16.0.1.0.0",
"category": "Storage",
"website": "https://github.com/OCA/storage",
"author": " Akretion, Odoo Community Association (OCA)",
Expand Down
39 changes: 26 additions & 13 deletions storage_backend_s3/tests/test_amazon_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
import logging
import os

from vcr_unittest import VCRMixin
from vcr import VCR

from odoo.addons.storage_backend.tests.common import BackendStorageTestMixin, CommonCase

_logger = logging.getLogger(__name__)

recorder = VCR(
record_mode='once',
cassette_library_dir='cassettes',
path_transformer=VCR.ensure_suffix('.yaml'),
filter_headers=['Authorization'],
)

class AmazonS3Case(VCRMixin, CommonCase, BackendStorageTestMixin):
def _get_vcr_kwargs(self, **kwargs):
return {
"record_mode": "once",
"match_on": ["method", "path", "query", "body"],
"filter_headers": ["Authorization"],
"decode_compressed_response": True,
}

def setUp(self):
super(AmazonS3Case, self).setUp()
self.backend.write(
class AmazonS3Case(CommonCase, BackendStorageTestMixin):
@classmethod
def setUpClass(cls):
super(AmazonS3Case, cls).setUpClass()
cls.backend = cls.env["storage.backend"].create(
{
"backend_type": "amazon_s3",
"aws_bucket": os.environ.get("AWS_BUCKET", "test-storage-backend"),
Expand All @@ -37,12 +37,23 @@ def setUp(self):
}
)

def _get_vcr_kwargs(self, **kwargs):
return {
"record_mode": "once",
"match_on": ["method", "path", "query", "body"],
"filter_headers": ["Authorization"],
"decode_compressed_response": True,
}

@recorder.use_cassette
def test_setting_and_getting_data_from_root(self):
self._test_setting_and_getting_data_from_root()


@recorder.use_cassette
def test_setting_and_getting_data_from_dir(self):
self._test_setting_and_getting_data_from_dir()

@recorder.use_cassette
def test_params(self):
adapter = self.backend._get_adapter()
self.backend.aws_host = ""
Expand All @@ -52,6 +63,7 @@ def test_params(self):
params = adapter._aws_bucket_params()
self.assertEqual(params["endpoint_url"], "another.s3.endpoint.com")

@recorder.use_cassette
def test_aws_other_region_filled(self):
adapter = self.backend._get_adapter()
self.assertFalse(self.backend.aws_region)
Expand All @@ -63,6 +75,7 @@ def test_aws_other_region_filled(self):
params = adapter._aws_bucket_params()
self.assertEqual(params["region_name"], "fr-par")

@recorder.use_cassette
def test_aws_other_region_empty(self):
self.backend.aws_other_region = ""
adapter = self.backend._get_adapter()
Expand Down

0 comments on commit 465cb1d

Please sign in to comment.