Skip to content

Commit 95c09a6

Browse files
committed
added tests
1 parent 70c1c73 commit 95c09a6

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

tests/custom_metric/__init__.py

Whitespace-only changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import uuid
2+
3+
from temporalio import activity
4+
from temporalio.testing import WorkflowEnvironment
5+
from temporalio.worker import Worker
6+
7+
from custom_metric.worker import ExecuteActivityWorkflow
8+
9+
_TASK_QUEUE = "custom-metric-task-queue"
10+
11+
activity_counter = 0
12+
13+
14+
async def test_sleep_for_days_workflow():
15+
16+
@activity.defn(name="print_message")
17+
async def print_message_mock():
18+
global activity_counter
19+
activity_counter += 1
20+
21+
async with await WorkflowEnvironment.start_time_skipping() as env:
22+
23+
async with Worker(
24+
env.client,
25+
task_queue=_TASK_QUEUE,
26+
workflows=[ExecuteActivityWorkflow],
27+
activities=[print_message_mock],
28+
):
29+
result = await env.client.execute_workflow(
30+
ExecuteActivityWorkflow.run,
31+
id=str(uuid.uuid4()),
32+
task_queue=_TASK_QUEUE,
33+
)
34+
assert result is None
35+
assert activity_counter == 2

0 commit comments

Comments
 (0)