Skip to content

Commit 3f41215

Browse files
committed
Cleanup
1 parent 3d2981d commit 3f41215

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

tests/test_serialization_context.py

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,8 +1129,6 @@ async def run(self, data: str) -> str:
11291129

11301130
async def test_codec_with_context(client: Client):
11311131
workflow_id = str(uuid.uuid4())
1132-
task_queue = str(uuid.uuid4())
1133-
11341132
client = Client(
11351133
**{
11361134
**client.config(),
@@ -1139,17 +1137,16 @@ async def test_codec_with_context(client: Client):
11391137
),
11401138
}
11411139
)
1142-
11431140
async with Worker(
11441141
client,
1145-
task_queue=task_queue,
1142+
task_queue=str(uuid.uuid4()),
11461143
workflows=[CodecTestWorkflow],
1147-
):
1144+
) as worker:
11481145
await client.execute_workflow(
11491146
CodecTestWorkflow.run,
11501147
"data",
11511148
id=workflow_id,
1152-
task_queue=task_queue,
1149+
task_queue=worker.task_queue,
11531150
)
11541151
workflow_context = dataclasses.asdict(
11551152
WorkflowSerializationContext(
@@ -1290,8 +1287,6 @@ async def run(self, data: TraceData) -> TraceData:
12901287

12911288
async def test_child_workflow_codec_with_context(client: Client):
12921289
workflow_id = str(uuid.uuid4())
1293-
task_queue = str(uuid.uuid4())
1294-
12951290
client = Client(
12961291
**{
12971292
**client.config(),
@@ -1301,18 +1296,17 @@ async def test_child_workflow_codec_with_context(client: Client):
13011296
),
13021297
}
13031298
)
1304-
13051299
async with Worker(
13061300
client,
1307-
task_queue=task_queue,
1301+
task_queue=str(uuid.uuid4()),
13081302
workflows=[ChildWorkflowCodecTestWorkflow, EchoWorkflow],
13091303
workflow_runner=UnsandboxedWorkflowRunner(),
1310-
):
1304+
) as worker:
13111305
await client.execute_workflow(
13121306
ChildWorkflowCodecTestWorkflow.run,
13131307
TraceData(),
13141308
id=workflow_id,
1315-
task_queue=task_queue,
1309+
task_queue=worker.task_queue,
13161310
)
13171311

13181312
parent_workflow_context = dataclasses.asdict(
@@ -1510,9 +1504,6 @@ async def test_payload_encryption_with_context(
15101504
"Encrypt" outbound payloads with a key using all available context fields, in order to demonstrate
15111505
that the same context is available to decrypt inbound payloads.
15121506
"""
1513-
workflow_id = str(uuid.uuid4())
1514-
task_queue = str(uuid.uuid4())
1515-
15161507
client = Client(
15171508
**{
15181509
**client.config(),
@@ -1522,19 +1513,18 @@ async def test_payload_encryption_with_context(
15221513
),
15231514
}
15241515
)
1525-
15261516
async with Worker(
15271517
client,
1528-
task_queue=task_queue,
1518+
task_queue=str(uuid.uuid4()),
15291519
workflows=[PayloadEncryptionWorkflow, PayloadEncryptionChildWorkflow],
15301520
activities=[payload_encryption_activity],
15311521
nexus_service_handlers=[PayloadEncryptionServiceHandler()],
1532-
):
1522+
) as worker:
15331523
wf_handle = await client.start_workflow(
15341524
PayloadEncryptionWorkflow.run,
15351525
"outbound",
1536-
id=workflow_id,
1537-
task_queue=task_queue,
1526+
id=str(uuid.uuid4()),
1527+
task_queue=worker.task_queue,
15381528
)
15391529
assert "inbound" == await wf_handle.query(
15401530
PayloadEncryptionWorkflow.query, "outbound"
@@ -1672,9 +1662,7 @@ async def run(self, data: PydanticData) -> PydanticData:
16721662

16731663

16741664
async def test_pydantic_converter_with_context(client: Client):
1675-
wf_id = str(uuid.uuid4())
1676-
task_queue = str(uuid.uuid4())
1677-
1665+
workflow_id = str(uuid.uuid4())
16781666
client = Client(
16791667
**{
16801668
**client.config(),
@@ -1687,13 +1675,13 @@ async def test_pydantic_converter_with_context(client: Client):
16871675

16881676
async with Worker(
16891677
client,
1690-
task_queue=task_queue,
1678+
task_queue=str(uuid.uuid4()),
16911679
workflows=[PydanticContextWorkflow],
1692-
):
1680+
) as worker:
16931681
result = await client.execute_workflow(
16941682
PydanticContextWorkflow.run,
16951683
PydanticData(value="test"),
1696-
id=wf_id,
1697-
task_queue=task_queue,
1684+
id=workflow_id,
1685+
task_queue=worker.task_queue,
16981686
)
1699-
assert f"wf_{wf_id}" in result.trace
1687+
assert f"wf_{workflow_id}" in result.trace

0 commit comments

Comments
 (0)