forked from temporalio/samples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello_child_test.py
More file actions
48 lines (40 loc) · 1.35 KB
/
hello_child_test.py
File metadata and controls
48 lines (40 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import uuid
from temporalio import workflow
from temporalio.client import Client
from temporalio.worker import Worker
from hello.hello_child_workflow import (
ComposeGreetingInput,
ComposeGreetingWorkflow,
GreetingWorkflow,
)
async def test_child_workflow(client: Client):
task_queue_name = str(uuid.uuid4())
async with Worker(
client,
task_queue=task_queue_name,
workflows=[GreetingWorkflow, ComposeGreetingWorkflow],
):
assert "Hello, World!" == await client.execute_workflow(
GreetingWorkflow.run,
"World",
id=str(uuid.uuid4()),
task_queue=task_queue_name,
)
@workflow.defn(name="ComposeGreetingWorkflow")
class MockedComposeGreetingWorkflow:
@workflow.run
async def run(self, input: ComposeGreetingInput) -> str:
return f"{input.greeting}, {input.name} from mocked child!"
async def test_mock_child_workflow(client: Client):
task_queue_name = str(uuid.uuid4())
async with Worker(
client,
task_queue=task_queue_name,
workflows=[GreetingWorkflow, MockedComposeGreetingWorkflow],
):
assert "Hello, World from mocked child!" == await client.execute_workflow(
GreetingWorkflow.run,
"World",
id=str(uuid.uuid4()),
task_queue=task_queue_name,
)