Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0560628

Browse files
authored
add-hello-query-test (temporalio#29)
1 parent c682a36 commit 0560628

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/hello/hello_query_test.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import uuid
2+
3+
from temporalio.testing import WorkflowEnvironment
4+
from temporalio.worker import Worker
5+
6+
from hello.hello_query import GreetingWorkflow
7+
8+
9+
async def test_query_workflow():
10+
task_queue_name = str(uuid.uuid4())
11+
# start manual time skipping
12+
async with await WorkflowEnvironment.start_time_skipping() as env:
13+
async with Worker(
14+
env.client, task_queue=task_queue_name, workflows=[GreetingWorkflow]
15+
):
16+
handle = await env.client.start_workflow(
17+
GreetingWorkflow.run,
18+
"World",
19+
id=str(uuid.uuid4()),
20+
task_queue=task_queue_name,
21+
)
22+
23+
assert "Hello, World!" == await handle.query(GreetingWorkflow.greeting)
24+
# manually skip 3 seconds. This will allow the workflow execution to move forward
25+
await env.sleep(3)
26+
assert "Goodbye, World!" == await handle.query(GreetingWorkflow.greeting)

0 commit comments

Comments
 (0)