Skip to content

Commit 9a5424c

Browse files
authored
add test to hello_child sample (temporalio#77)
1 parent 6fcb09d commit 9a5424c

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/hello/hello_child_test.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import uuid
2+
3+
from temporalio import workflow
4+
from temporalio.client import Client
5+
from temporalio.worker import Worker
6+
7+
from hello.hello_child_workflow import (
8+
ComposeGreetingInput,
9+
ComposeGreetingWorkflow,
10+
GreetingWorkflow,
11+
)
12+
13+
14+
async def test_child_workflow(client: Client):
15+
task_queue_name = str(uuid.uuid4())
16+
async with Worker(
17+
client,
18+
task_queue=task_queue_name,
19+
workflows=[GreetingWorkflow, ComposeGreetingWorkflow],
20+
):
21+
assert "Hello, World!" == await client.execute_workflow(
22+
GreetingWorkflow.run,
23+
"World",
24+
id=str(uuid.uuid4()),
25+
task_queue=task_queue_name,
26+
)
27+
28+
29+
@workflow.defn(name="ComposeGreetingWorkflow")
30+
class MockedComposeGreetingWorkflow:
31+
@workflow.run
32+
async def run(self, input: ComposeGreetingInput) -> str:
33+
return f"{input.greeting}, {input.name} from mocked child!"
34+
35+
36+
async def test_mock_child_workflow(client: Client):
37+
task_queue_name = str(uuid.uuid4())
38+
async with Worker(
39+
client,
40+
task_queue=task_queue_name,
41+
workflows=[GreetingWorkflow, MockedComposeGreetingWorkflow],
42+
):
43+
assert "Hello, World from mocked child!" == await client.execute_workflow(
44+
GreetingWorkflow.run,
45+
"World",
46+
id=str(uuid.uuid4()),
47+
task_queue=task_queue_name,
48+
)

0 commit comments

Comments
 (0)