Skip to content

Commit 10ee9da

Browse files
committed
fully support 6.X, fixed unit test
1 parent c1bb9ff commit 10ee9da

12 files changed

+35
-29
lines changed

.coveragerc

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ omit =
66
pynamodb_mate/docs/*
77
pynamodb_mate/tests/*
88
pynamodb_mate/vendor/*
9-
pynamodb_mate/paths
9+
pynamodb_mate/paths.py
1010

1111
[report]
1212
# Regexes for lines to exclude from consideration

pynamodb_mate/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "5.5.1.1"
1+
__version__ = "6.0.0.1"
22

33
if __name__ == "__main__": # pragma: no cover
44
print(__version__)

pynamodb_mate/attributes/encrypted.py

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(
3030
default: T.Optional[T.Callable] = None,
3131
default_for_new: T.Optional[T.Callable] = None,
3232
attr_name: T.Optional[str] = None,
33+
legacy_encoding: bool = False,
3334
):
3435
super().__init__(
3536
hash_key=hash_key,
@@ -38,6 +39,7 @@ def __init__(
3839
default=default,
3940
default_for_new=default_for_new,
4041
attr_name=attr_name,
42+
legacy_encoding=legacy_encoding,
4143
)
4244
self.encryption_key = encryption_key
4345
self.determinative = determinative

pynamodb_mate/models.py

-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
from pynamodb.models import Model as PynamodbModel
1313
from pynamodb.indexes import GlobalSecondaryIndex, LocalSecondaryIndex
14-
from pynamodb.settings import OperationSettings
1514
from pynamodb.exceptions import DeleteError
1615
from pynamodb.expressions.condition import Condition
1716

@@ -132,7 +131,6 @@ def get_one_or_none(
132131
range_key: T.Optional[T.Any] = None,
133132
consistent_read: bool = False,
134133
attributes_to_get: T.Optional[T.Sequence[str]] = None,
135-
settings: OperationSettings = OperationSettings.default,
136134
) -> T.Optional["Model"]:
137135
"""
138136
Get one Dynamodb item object or None if not exists.
@@ -145,7 +143,6 @@ def get_one_or_none(
145143
range_key=range_key,
146144
consistent_read=consistent_read,
147145
attributes_to_get=attributes_to_get,
148-
settings=settings,
149146
)
150147
except cls.DoesNotExist:
151148
return None
@@ -240,7 +237,6 @@ def iter_scan(
240237
index_name: T.Optional[str] = None,
241238
rate_limit: T.Optional[float] = None,
242239
attributes_to_get: T.Optional[T.Sequence[str]] = None,
243-
settings: OperationSettings = OperationSettings.default,
244240
) -> IterProxy[_T]:
245241
"""
246242
Similar to the ``Model.scan()`` method, but it returns
@@ -260,7 +256,6 @@ def iter_scan(
260256
index_name=index_name,
261257
rate_limit=rate_limit,
262258
attributes_to_get=attributes_to_get,
263-
settings=settings,
264259
)
265260
)
266261

@@ -278,7 +273,6 @@ def iter_query(
278273
attributes_to_get: T.Optional[T.Iterable[str]] = None,
279274
page_size: T.Optional[int] = None,
280275
rate_limit: T.Optional[float] = None,
281-
settings: OperationSettings = OperationSettings.default,
282276
) -> IterProxy[_T]:
283277
"""
284278
Similar to the ``Model.query()`` method, but it returns
@@ -299,7 +293,6 @@ def iter_query(
299293
attributes_to_get=attributes_to_get,
300294
page_size=page_size,
301295
rate_limit=rate_limit,
302-
settings=settings,
303296
)
304297
)
305298

pynamodb_mate/patterns/cache/backend/dynamodb.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class DynamoDBTable(Model):
7373
Meta = Meta_
7474

7575
key: str = UnicodeAttribute(hash_key=True)
76-
value: bytes = BinaryAttribute()
76+
value: bytes = BinaryAttribute(legacy_encoding=False)
7777
expire: int = NumberAttribute()
7878
update_ts: int = NumberAttribute()
7979

pynamodb_mate/patterns/status_tracker/impl.py

-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
GlobalSecondaryIndex,
2626
IncludeProjection,
2727
)
28-
from pynamodb.settings import OperationSettings
2928

3029
from ...models import Model
3130
from ...compat import cached_property
@@ -327,7 +326,6 @@ def get_one_or_none(
327326
task_id: str,
328327
consistent_read: bool = False,
329328
attributes_to_get: T.Optional[T.Sequence[str]] = None,
330-
settings: OperationSettings = OperationSettings.default,
331329
job_id: T.Optional[str] = None,
332330
) -> T.Optional["BaseStatusTracker"]:
333331
"""
@@ -338,7 +336,6 @@ def get_one_or_none(
338336
hash_key=cls.make_key(task_id, JOB_ID),
339337
consistent_read=consistent_read,
340338
attributes_to_get=attributes_to_get,
341-
settings=settings,
342339
)
343340

344341
def is_item_exists(self) -> bool:

release-history.rst

+14-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ Backlog
88
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99
**Features and Improvements**
1010

11-
- add automatically rollback if one of the DynamoDB write or S3 write failed.
12-
- add an option to delete the S3 object as well when the DynamoDB item is deleted.
13-
- add lazy load option for S3BackedAttribute.
1411
- add ``clear_expired()`` method to DynamoDB cache backend.
15-
- add ``large_attribute`` pattern.
12+
13+
**Minor Improvements**
14+
15+
**Bugfixes**
16+
17+
**Miscellaneous**
18+
19+
20+
6.0.0.1 (Planned)
21+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22+
**Features and Improvements**
23+
24+
- fully support pynamodb 6.X, drop compatible to pynamodb 5.X.
25+
- add the ``status_tracker_v2`` pattern to ensure strong consistency in high concurrent workload.
1626

1727
**Minor Improvements**
1828

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pynamodb>=5.5.1,<6.0.0
1+
pynamodb>=6.0.0,<7.0.0
22
cached-property>=1.5.2; python_version < '3.8'
33
dataclasses>=0.8; python_version == '3.6'
44
iterproxy>=0.3.1,<1.0.0

tests/patterns/test_large_attribute.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,9 @@ class TestLargeAttributeUseMock(Base):
607607
use_mock = True
608608

609609

610-
# @pytest.mark.skipif(IS_CI, reason="Skip test that requires AWS resources in CI.")
611-
# class TestLargeAttributeUseAws(Base):
612-
# use_mock = False
610+
@pytest.mark.skipif(IS_CI, reason="Skip test that requires AWS resources in CI.")
611+
class TestLargeAttributeUseAws(Base):
612+
use_mock = False
613613

614614

615615
if __name__ == "__main__":

tests/test_attr_compressed.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class Meta:
1717
# fmt: off
1818
order_id: pm.REQUIRED_STR = pm.UnicodeAttribute(hash_key=True)
1919
# original value is unicode str
20-
description: pm.OPTIONAL_BINARY = pm.attributes.CompressedUnicodeAttribute(null=True)
20+
description: pm.OPTIONAL_BINARY = pm.attributes.CompressedUnicodeAttribute(null=True, legacy_encoding=False)
2121
# original value is binary bytes
22-
image: pm.OPTIONAL_BINARY = pm.attributes.CompressedBinaryAttribute(null=True)
22+
image: pm.OPTIONAL_BINARY = pm.attributes.CompressedBinaryAttribute(null=True, legacy_encoding=False)
2323
# original value is any json serializable object
24-
items: pm.OPTIONAL_BINARY = pm.attributes.CompressedJSONDictAttribute(null=True)
24+
items: pm.OPTIONAL_BINARY = pm.attributes.CompressedJSONDictAttribute(null=True, legacy_encoding=False)
2525
# fmt: on
2626

2727

tests/test_attr_encrypted.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import pytest
44

5-
from boto_session_manager import BotoSesManager
65
import pynamodb_mate.api as pm
7-
from pynamodb_mate.tests.constants import PY_VER, PYNAMODB_VER, AWS_PROFILE, IS_CI
6+
from pynamodb_mate.tests.constants import PY_VER, PYNAMODB_VER, IS_CI
87
from pynamodb_mate.tests.base_test import BaseTest
98

109
ENCRYPTION_KEY = "my-password"
@@ -20,22 +19,27 @@ class Meta:
2019
secret_message: pm.REQUIRED_BINARY = pm.attributes.EncryptedUnicodeAttribute(
2120
encryption_key=ENCRYPTION_KEY,
2221
determinative=True,
22+
legacy_encoding=False,
2323
)
2424
secret_binary: pm.REQUIRED_BINARY = pm.attributes.EncryptedBinaryAttribute(
2525
encryption_key=ENCRYPTION_KEY,
2626
determinative=False,
27+
legacy_encoding=False,
2728
)
2829
secret_integer: pm.REQUIRED_BINARY = pm.attributes.EncryptedNumberAttribute(
2930
encryption_key=ENCRYPTION_KEY,
3031
determinative=True,
32+
legacy_encoding=False,
3133
)
3234
secret_float: pm.REQUIRED_BINARY = pm.attributes.EncryptedNumberAttribute(
3335
encryption_key=ENCRYPTION_KEY,
3436
determinative=False,
37+
legacy_encoding=False,
3538
)
3639
secret_data: pm.REQUIRED_BINARY = pm.attributes.EncryptedJsonDictAttribute(
3740
encryption_key=ENCRYPTION_KEY,
3841
determinative=False,
42+
legacy_encoding=False,
3943
)
4044

4145

tests/test_attr_s3backed.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ class TestS3BackedAttributeUseMock(Base):
137137
use_mock = True
138138

139139

140-
# @pytest.mark.skipif(IS_CI, reason="Skip test that requires AWS resources in CI.")
141-
# class TestS3BackedAttributeUseAws(Base):
142-
# use_mock = False
140+
@pytest.mark.skipif(IS_CI, reason="Skip test that requires AWS resources in CI.")
141+
class TestS3BackedAttributeUseAws(Base):
142+
use_mock = False
143143

144144

145145
if __name__ == "__main__":

0 commit comments

Comments
 (0)