From fe45e0b9f53815baf41d029c2223a2d3d1bd6c59 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Thu, 22 Feb 2024 04:55:27 +1100 Subject: [PATCH] Unpin moto, and support moto 5.0 changes To stop testing with old versions of moto, unpin it from version 3, to the latest, depending on the Python version being used. Support both version 4 and 5 in the test suite. --- requirements/testing.txt | 5 ++++- .../oauth/installation_store/test_amazon_s3.py | 12 ++++++++---- tests/slack_sdk/oauth/state_store/test_amazon_s3.py | 12 ++++++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/requirements/testing.txt b/requirements/testing.txt index 0a4d7ae9f..82337fe14 100644 --- a/requirements/testing.txt +++ b/requirements/testing.txt @@ -14,4 +14,7 @@ click==8.0.4 # black is affected by https://github.com/pallets/click/issues/222 psutil>=5,<6 # used only under slack_sdk/*_store boto3<=2 -moto>=3,<4 # For AWS tests +# For AWS tests +moto==4.0.13; python_version=="3.6" +moto<5; python_version=="3.7" +moto<6 diff --git a/tests/slack_sdk/oauth/installation_store/test_amazon_s3.py b/tests/slack_sdk/oauth/installation_store/test_amazon_s3.py index ab4b25fb4..a51f37e9d 100644 --- a/tests/slack_sdk/oauth/installation_store/test_amazon_s3.py +++ b/tests/slack_sdk/oauth/installation_store/test_amazon_s3.py @@ -1,23 +1,27 @@ import unittest import boto3 -from moto import mock_s3 + +try: + from moto import mock_aws +except ImportError: + from moto import mock_s3 as mock_aws from slack_sdk.oauth.installation_store import Installation from slack_sdk.oauth.installation_store.amazon_s3 import AmazonS3InstallationStore class TestAmazonS3(unittest.TestCase): - mock_s3 = mock_s3() + mock_aws = mock_aws() bucket_name = "test-bucket" def setUp(self): - self.mock_s3.start() + self.mock_aws.start() s3 = boto3.resource("s3") bucket = s3.Bucket(self.bucket_name) bucket.create(CreateBucketConfiguration={"LocationConstraint": "af-south-1"}) def tearDown(self): - self.mock_s3.stop() + self.mock_aws.stop() def build_store(self) -> AmazonS3InstallationStore: return AmazonS3InstallationStore( diff --git a/tests/slack_sdk/oauth/state_store/test_amazon_s3.py b/tests/slack_sdk/oauth/state_store/test_amazon_s3.py index 8561eeb62..277b8b83a 100644 --- a/tests/slack_sdk/oauth/state_store/test_amazon_s3.py +++ b/tests/slack_sdk/oauth/state_store/test_amazon_s3.py @@ -1,22 +1,26 @@ import unittest import boto3 -from moto import mock_s3 + +try: + from moto import mock_aws +except ImportError: + from moto import mock_s3 as mock_aws from slack_sdk.oauth.state_store.amazon_s3 import AmazonS3OAuthStateStore class TestAmazonS3(unittest.TestCase): - mock_s3 = mock_s3() + mock_aws = mock_aws() bucket_name = "test-bucket" def setUp(self): - self.mock_s3.start() + self.mock_aws.start() s3 = boto3.resource("s3") bucket = s3.Bucket(self.bucket_name) bucket.create(CreateBucketConfiguration={"LocationConstraint": "af-south-1"}) def tearDown(self): - self.mock_s3.stop() + self.mock_aws.stop() def test_instance(self): store = AmazonS3OAuthStateStore(