Skip to content

Commit afdb757

Browse files
committed
Add test
1 parent 70612e5 commit afdb757

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

tests/worker/test_activity.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,3 +1551,33 @@ def sync_wait_cancel() -> str:
15511551
worker_config=config,
15521552
)
15531553
assert result.result == "Got cancelled error, reset? True"
1554+
1555+
1556+
async def test_activity_reset_history(client: Client, worker: ExternalWorker):
1557+
@activity.defn
1558+
async def wait_cancel() -> str:
1559+
req = temporalio.api.workflowservice.v1.ResetActivityRequest(
1560+
namespace=client.namespace,
1561+
execution=temporalio.api.common.v1.WorkflowExecution(
1562+
workflow_id=activity.info().workflow_id,
1563+
run_id=activity.info().workflow_run_id,
1564+
),
1565+
id=activity.info().activity_id,
1566+
)
1567+
await client.workflow_service.reset_activity(req)
1568+
while True:
1569+
await asyncio.sleep(0.3)
1570+
activity.heartbeat()
1571+
1572+
with pytest.raises(WorkflowFailureError) as e:
1573+
result = await _execute_workflow_with_activity(
1574+
client,
1575+
worker,
1576+
wait_cancel,
1577+
)
1578+
assert isinstance(e.value.cause, ActivityError)
1579+
assert isinstance(e.value.cause.cause, ApplicationError)
1580+
assert (
1581+
e.value.cause.cause.message
1582+
== "Unhandled activity cancel error produced by activity reset"
1583+
)

tests/worker/test_workflow.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8330,4 +8330,3 @@ async def test_workflow_headers_with_codec(
83308330
assert headers["foo"].data == b"bar"
83318331
else:
83328332
assert headers["foo"].data != b"bar"
8333-

0 commit comments

Comments
 (0)