-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use temporalio.testing.ActivityEnvironment (#96)
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pytest | ||
from temporalio.testing import ActivityEnvironment | ||
|
||
from hello.hello_activity_choice import ( | ||
order_apples, | ||
order_bananas, | ||
order_cherries, | ||
order_oranges, | ||
) | ||
|
||
# A list of tuples where each tuple contains: | ||
# - The activity function | ||
# - The order amount | ||
# - The expected result string | ||
activity_test_data = [ | ||
(order_apples, 5, "Ordered 5 Apples..."), | ||
(order_bananas, 5, "Ordered 5 Bananas..."), | ||
(order_cherries, 5, "Ordered 5 Cherries..."), | ||
(order_oranges, 5, "Ordered 5 Oranges..."), | ||
] | ||
|
||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.parametrize( | ||
"activity_func, order_amount, expected_result", activity_test_data | ||
) | ||
async def test_order_fruit(activity_func, order_amount, expected_result): | ||
activity_environment = ActivityEnvironment() | ||
|
||
result = await activity_environment.run(activity_func, order_amount) | ||
|
||
assert result == expected_result |