Skip to content

Commit 01d9af8

Browse files
committed
Formatting
1 parent 2abe719 commit 01d9af8

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

tests/worker/test_workflow.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import temporalio.activity
4545
import temporalio.api.sdk.v1
4646
import temporalio.client
47+
import temporalio.converter
4748
import temporalio.worker
4849
import temporalio.workflow
4950
from temporalio import activity, workflow
@@ -8370,12 +8371,17 @@ async def test_previous_run_failure(client: Client):
83708371
result = await handle.result()
83718372
assert result == "Done"
83728373

8374+
83738375
class EncryptionCodec(PayloadCodec):
8374-
def __init__(self, key_id: str = "test-key-id", key: bytes = b"test-key-test-key-test-key-test!") -> None:
8376+
def __init__(
8377+
self,
8378+
key_id: str = "test-key-id",
8379+
key: bytes = b"test-key-test-key-test-key-test!",
8380+
) -> None:
83758381
super().__init__()
83768382
self.key_id = key_id
83778383

8378-
async def encode(self, payloads: Iterable[Payload]) -> List[Payload]:
8384+
async def encode(self, payloads: Sequence[Payload]) -> List[Payload]:
83798385
# We blindly encode all payloads with the key and set the metadata
83808386
# saying which key we used
83818387
return [
@@ -8389,7 +8395,7 @@ async def encode(self, payloads: Iterable[Payload]) -> List[Payload]:
83898395
for p in payloads
83908396
]
83918397

8392-
async def decode(self, payloads: Iterable[Payload]) -> List[Payload]:
8398+
async def decode(self, payloads: Sequence[Payload]) -> List[Payload]:
83938399
ret: List[Payload] = []
83948400
for p in payloads:
83958401
# Ignore ones w/out our expected encoding
@@ -8399,7 +8405,9 @@ async def decode(self, payloads: Iterable[Payload]) -> List[Payload]:
83998405
# Confirm our key ID is the same
84008406
key_id = p.metadata.get("encryption-key-id", b"").decode()
84018407
if key_id != self.key_id:
8402-
raise ValueError(f"Unrecognized key ID {key_id}. Current key ID is {self.key_id}.")
8408+
raise ValueError(
8409+
f"Unrecognized key ID {key_id}. Current key ID is {self.key_id}."
8410+
)
84038411
# Decrypt and append
84048412
ret.append(Payload.FromString(self.decrypt(p.data)))
84058413
return ret
@@ -8435,20 +8443,24 @@ class SearchAttributeCodecChildWorkflow:
84358443
async def run(self, name: str) -> str:
84368444
return f"Hello from child, {name}"
84378445

8446+
84388447
async def test_search_attribute_codec(client: Client):
84398448
await ensure_search_attributes_present(
84408449
client,
84418450
SearchAttributeCodecParentWorkflow.text_attribute,
84428451
)
84438452

84448453
config = client.config()
8445-
config["data_converter"] = dataclasses.replace(temporalio.converter.default(), payload_codec=EncryptionCodec())
8454+
config["data_converter"] = dataclasses.replace(
8455+
temporalio.converter.default(), payload_codec=EncryptionCodec()
8456+
)
84468457
client = Client(**config)
84478458

84488459
# Run a worker for the workflow
84498460
async with new_worker(
84508461
client,
8451-
SearchAttributeCodecParentWorkflow, SearchAttributeCodecChildWorkflow,
8462+
SearchAttributeCodecParentWorkflow,
8463+
SearchAttributeCodecChildWorkflow,
84528464
) as worker:
84538465
# Run workflow
84548466
result = await client.execute_workflow(
@@ -8457,6 +8469,10 @@ async def test_search_attribute_codec(client: Client):
84578469
id=f"encryption-workflow-id",
84588470
task_queue=worker.task_queue,
84598471
search_attributes=TypedSearchAttributes(
8460-
[SearchAttributePair(SearchAttributeCodecParentWorkflow.text_attribute, "test_text")]
8472+
[
8473+
SearchAttributePair(
8474+
SearchAttributeCodecParentWorkflow.text_attribute, "test_text"
8475+
)
8476+
]
84618477
),
8462-
)
8478+
)

0 commit comments

Comments
 (0)