Skip to content

Commit

Permalink
Use temporalio.testing.ActivityEnvironment (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
rachfop authored Nov 27, 2023
1 parent 68ba233 commit ecdfcd6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/hello/hello_activity_choice_test.py
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

0 comments on commit ecdfcd6

Please sign in to comment.