Skip to content

Commit 0e0ce65

Browse files
committed
autoformat
1 parent 2a71472 commit 0e0ce65

File tree

4 files changed

+20
-50
lines changed

4 files changed

+20
-50
lines changed

test/functional/encrypted/test_resource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"""Functional tests for ``dynamodb_encryption_sdk.encrypted.resource``."""
1414
import pytest
1515

16-
from ..functional_test_utils import example_table # noqa pylint: disable=unused-import
16+
from ..functional_test_utils import example_table # noqa pylint: disable=unused-import
1717
from ..functional_test_utils import (
1818
TEST_TABLE_NAME,
1919
build_static_jce_cmp,

test/functional/encrypted/test_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import hypothesis
1515
import pytest
1616

17-
from ..functional_test_utils import example_table # noqa pylint: disable=unused-import
17+
from ..functional_test_utils import example_table # noqa pylint: disable=unused-import
1818
from ..functional_test_utils import (
1919
TEST_TABLE_NAME,
2020
build_static_jce_cmp,

test/functional/functional_test_utils.py

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,7 @@ def diverse_item():
338338

339339

340340
def return_requestitems_as_unprocessed(*args, **kwargs):
341-
return {
342-
"UnprocessedItems": kwargs['RequestItems']
343-
}
341+
return {"UnprocessedItems": kwargs["RequestItems"]}
344342

345343

346344
def check_encrypted_item(plaintext_item, ciphertext_item, attribute_actions):
@@ -495,10 +493,7 @@ def cycle_batch_writer_check(raw_table, encrypted_table, initial_actions, initia
495493

496494

497495
def batch_write_item_unprocessed_check(
498-
encrypted,
499-
initial_item,
500-
write_transformer=_nop_transformer,
501-
table_name=TEST_TABLE_NAME,
496+
encrypted, initial_item, write_transformer=_nop_transformer, table_name=TEST_TABLE_NAME
502497
):
503498
"""Check that unprocessed items in a batch result are unencrypted."""
504499
items = _generate_items(initial_item, write_transformer)
@@ -565,11 +560,7 @@ def table_cycle_batch_writer_check(materials_provider, initial_actions, initial_
565560

566561

567562
def table_batch_writer_unprocessed_items_check(
568-
materials_provider,
569-
initial_actions,
570-
initial_item,
571-
table_name,
572-
region_name=None
563+
materials_provider, initial_actions, initial_item, table_name, region_name=None
573564
):
574565
kwargs = {}
575566
if region_name is not None:
@@ -582,7 +573,7 @@ def table_batch_writer_unprocessed_items_check(
582573

583574
with patch.object(table.meta.client, "batch_write_item") as batch_write_mock:
584575
# Check that unprocessed items returned to a BatchWriter are successfully retried
585-
batch_write_mock.side_effect = [{"UnprocessedItems": request_items}, {'UnprocessedItems': {}}]
576+
batch_write_mock.side_effect = [{"UnprocessedItems": request_items}, {"UnprocessedItems": {}}]
586577
e_table = EncryptedTable(table=table, materials_provider=materials_provider, attribute_actions=initial_actions)
587578

588579
with e_table.batch_writer() as writer:
@@ -616,27 +607,20 @@ def resource_cycle_batch_items_check(materials_provider, initial_actions, initia
616607

617608

618609
def resource_batch_items_unprocessed_check(
619-
materials_provider,
620-
initial_actions,
621-
initial_item,
622-
table_name,
623-
region_name=None
610+
materials_provider, initial_actions, initial_item, table_name, region_name=None
624611
):
625612
kwargs = {}
626613
if region_name is not None:
627614
kwargs["region_name"] = region_name
628-
resource = boto3.resource('dynamodb', **kwargs)
615+
resource = boto3.resource("dynamodb", **kwargs)
629616

630617
with patch.object(resource, "batch_write_item", return_requestitems_as_unprocessed):
631618
e_resource = EncryptedResource(
632619
resource=resource, materials_provider=materials_provider, attribute_actions=initial_actions
633620
)
634621

635622
batch_write_item_unprocessed_check(
636-
encrypted=e_resource,
637-
initial_item=initial_item,
638-
write_transformer=dict_to_ddb,
639-
table_name=table_name,
623+
encrypted=e_resource, initial_item=initial_item, write_transformer=dict_to_ddb, table_name=table_name
640624
)
641625

642626

@@ -691,27 +675,20 @@ def client_cycle_batch_items_check(materials_provider, initial_actions, initial_
691675

692676

693677
def client_batch_items_unprocessed_check(
694-
materials_provider,
695-
initial_actions,
696-
initial_item,
697-
table_name,
698-
region_name=None
678+
materials_provider, initial_actions, initial_item, table_name, region_name=None
699679
):
700680
kwargs = {}
701681
if region_name is not None:
702682
kwargs["region_name"] = region_name
703-
client = boto3.client('dynamodb', **kwargs)
683+
client = boto3.client("dynamodb", **kwargs)
704684

705685
with patch.object(client, "batch_write_item", return_requestitems_as_unprocessed):
706686
e_client = EncryptedClient(
707687
client=client, materials_provider=materials_provider, attribute_actions=initial_actions
708688
)
709689

710690
batch_write_item_unprocessed_check(
711-
encrypted=e_client,
712-
initial_item=initial_item,
713-
write_transformer=dict_to_ddb,
714-
table_name=table_name,
691+
encrypted=e_client, initial_item=initial_item, write_transformer=dict_to_ddb, table_name=table_name
715692
)
716693

717694

test/functional/internal/test_utils.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,11 @@ def get_test_items(standard_dict_format, table_name="table", with_sort_keys=Fals
6262
def get_dummy_crypto_config(partition_key_name=None, sort_key_name=None, sign_keys=False):
6363
context = EncryptionContext(partition_key_name=partition_key_name, sort_key_name=sort_key_name)
6464
actions = AttributeActions(
65-
default_action=CryptoAction.DO_NOTHING,
66-
attribute_actions={
67-
"encrypt-me": CryptoAction.ENCRYPT_AND_SIGN
68-
},
65+
default_action=CryptoAction.DO_NOTHING, attribute_actions={"encrypt-me": CryptoAction.ENCRYPT_AND_SIGN}
6966
)
7067
if sign_keys:
71-
actions.attribute_actions['partition-key'] = CryptoAction.SIGN_ONLY
72-
actions.attribute_actions['sort-key'] = CryptoAction.SIGN_ONLY
68+
actions.attribute_actions["partition-key"] = CryptoAction.SIGN_ONLY
69+
actions.attribute_actions["sort-key"] = CryptoAction.SIGN_ONLY
7370

7471
materials = Mock(spec=CryptographicMaterialsProvider) # type: CryptographicMaterialsProvider
7572
return CryptoConfig(materials_provider=materials, encryption_context=context, attribute_actions=actions)
@@ -78,7 +75,7 @@ def get_dummy_crypto_config(partition_key_name=None, sort_key_name=None, sign_ke
7875
def check_encrypt_batch_write_item_call(request_items, crypto_config):
7976
def dummy_encrypt(item, **kwargs):
8077
result = item.copy()
81-
result['encrypt-me'] = "pretend Im encrypted"
78+
result["encrypt-me"] = "pretend Im encrypted"
8279
return result
8380

8481
# execute a batch write, but make the write method return ALL the provided items as unprocessed
@@ -96,11 +93,7 @@ def dummy_encrypt(item, **kwargs):
9693

9794

9895
@pytest.mark.parametrize(
99-
"items",
100-
(
101-
get_test_items(standard_dict_format=True),
102-
get_test_items(standard_dict_format=False),
103-
)
96+
"items", (get_test_items(standard_dict_format=True), get_test_items(standard_dict_format=False))
10497
)
10598
def test_encrypt_batch_write_returns_plaintext_unprocessed_items_with_known_partition_key(items):
10699
crypto_config = get_dummy_crypto_config("partition-key")
@@ -112,7 +105,7 @@ def test_encrypt_batch_write_returns_plaintext_unprocessed_items_with_known_part
112105
(
113106
get_test_items(standard_dict_format=True, with_sort_keys=True),
114107
get_test_items(standard_dict_format=False, with_sort_keys=True),
115-
)
108+
),
116109
)
117110
def test_encrypt_batch_write_returns_plaintext_unprocessed_items_with_known_partition_and_sort_keys(items):
118111
crypto_config = get_dummy_crypto_config("partition-key", "sort-key")
@@ -126,7 +119,7 @@ def test_encrypt_batch_write_returns_plaintext_unprocessed_items_with_known_part
126119
get_test_items(standard_dict_format=False),
127120
get_test_items(standard_dict_format=True, with_sort_keys=True),
128121
get_test_items(standard_dict_format=False, with_sort_keys=True),
129-
)
122+
),
130123
)
131124
def test_encrypt_batch_write_returns_plaintext_unprocessed_items_with_unknown_keys(items):
132125
crypto_config = get_dummy_crypto_config(None, None)
@@ -141,7 +134,7 @@ def test_encrypt_batch_write_returns_plaintext_unprocessed_items_with_unknown_ke
141134
get_test_items(standard_dict_format=False),
142135
get_test_items(standard_dict_format=True, with_sort_keys=True),
143136
get_test_items(standard_dict_format=False, with_sort_keys=True),
144-
)
137+
),
145138
)
146139
def test_encrypt_batch_write_returns_plaintext_unprocessed_items_with_unknown_signed_keys(items):
147140
crypto_config = get_dummy_crypto_config(None, None, sign_keys=True)

0 commit comments

Comments
 (0)