Skip to content

Commit

Permalink
Use largest version of moto possible
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
s-t-e-v-e-n-k committed Feb 20, 2024
1 parent 60b02d6 commit b0e4026
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
5 changes: 4 additions & 1 deletion requirements/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 8 additions & 4 deletions tests/slack_sdk/oauth/installation_store/test_amazon_s3.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
12 changes: 8 additions & 4 deletions tests/slack_sdk/oauth/state_store/test_amazon_s3.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down

0 comments on commit b0e4026

Please sign in to comment.