summaryrefslogtreecommitdiff
path: root/tests/integration/test_dynamodb.py
diff options
context:
space:
mode:
authorJordan Cook <JWCook@users.noreply.github.com>2021-04-22 13:27:24 -0500
committerGitHub <noreply@github.com>2021-04-22 13:27:24 -0500
commitf2bf9bbfd8d711e9dfc8ccce83f439d765d484cb (patch)
treefb617be7c7760390b7239899e6522d865956342f /tests/integration/test_dynamodb.py
parent38ddcf5425eadc6b174a8b053b2175c4dda00a1f (diff)
parent3ec85f0107caedbe3b3bd8080bd3dac81b7baa17 (diff)
downloadrequests-cache-f2bf9bbfd8d711e9dfc8ccce83f439d765d484cb.tar.gz
Merge pull request #242 from JWCook/integration-tests
Refactor backend integration tests
Diffstat (limited to 'tests/integration/test_dynamodb.py')
-rw-r--r--tests/integration/test_dynamodb.py34
1 files changed, 14 insertions, 20 deletions
diff --git a/tests/integration/test_dynamodb.py b/tests/integration/test_dynamodb.py
index 3a4bd23..951d9c8 100644
--- a/tests/integration/test_dynamodb.py
+++ b/tests/integration/test_dynamodb.py
@@ -1,10 +1,9 @@
import pytest
-import unittest
from unittest.mock import patch
-from requests_cache.backends import DynamoDbDict
+from requests_cache.backends import DynamoDbCache, DynamoDbDict
from tests.conftest import AWS_OPTIONS, fail_if_no_connection
-from tests.integration.test_backends import BaseStorageTestCase
+from tests.integration.test_backends import BaseCacheTest, BaseStorageTest
# Run this test module last, since the DynamoDB container takes the longest to initialize
pytestmark = pytest.mark.order(-1)
@@ -20,23 +19,18 @@ def ensure_connection():
client.describe_limits()
-class DynamoDbDictWrapper(DynamoDbDict):
- def __init__(self, namespace, collection_name='dynamodb_dict_data', **options):
- super().__init__(namespace, collection_name, **options, **AWS_OPTIONS)
+class TestDynamoDbDict(BaseStorageTest):
+ storage_class = DynamoDbDict
+ init_kwargs = AWS_OPTIONS
+ picklable = True
+ @patch('requests_cache.backends.dynamodb.boto3.resource')
+ def test_connection_kwargs(self, mock_resource):
+ """A spot check to make sure optional connection kwargs gets passed to connection"""
+ DynamoDbDict('test', region_name='us-east-2', invalid_kwarg='???')
+ mock_resource.assert_called_with('dynamodb', region_name='us-east-2')
-class DynamoDbTestCase(BaseStorageTestCase, unittest.TestCase):
- def __init__(self, *args, **kwargs):
- super().__init__(
- *args,
- storage_class=DynamoDbDictWrapper,
- picklable=True,
- **kwargs,
- )
-
-@patch('requests_cache.backends.dynamodb.boto3.resource')
-def test_connection_kwargs(mock_resource):
- """A spot check to make sure optional connection kwargs gets passed to connection"""
- DynamoDbDict('test', region_name='us-east-2', invalid_kwarg='???')
- mock_resource.assert_called_with('dynamodb', region_name='us-east-2')
+class TestDynamoDbCache(BaseCacheTest):
+ backend_class = DynamoDbCache
+ init_kwargs = AWS_OPTIONS