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

Skip to content

Commit ecdfcd6

Browse files
authored
Use temporalio.testing.ActivityEnvironment (temporalio#96)
1 parent 68ba233 commit ecdfcd6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import pytest
2+
from temporalio.testing import ActivityEnvironment
3+
4+
from hello.hello_activity_choice import (
5+
order_apples,
6+
order_bananas,
7+
order_cherries,
8+
order_oranges,
9+
)
10+
11+
# A list of tuples where each tuple contains:
12+
# - The activity function
13+
# - The order amount
14+
# - The expected result string
15+
activity_test_data = [
16+
(order_apples, 5, "Ordered 5 Apples..."),
17+
(order_bananas, 5, "Ordered 5 Bananas..."),
18+
(order_cherries, 5, "Ordered 5 Cherries..."),
19+
(order_oranges, 5, "Ordered 5 Oranges..."),
20+
]
21+
22+
23+
@pytest.mark.asyncio
24+
@pytest.mark.parametrize(
25+
"activity_func, order_amount, expected_result", activity_test_data
26+
)
27+
async def test_order_fruit(activity_func, order_amount, expected_result):
28+
activity_environment = ActivityEnvironment()
29+
30+
result = await activity_environment.run(activity_func, order_amount)
31+
32+
assert result == expected_result

0 commit comments

Comments
 (0)