Skip to content

Commit e289fab

Browse files
committed
Print history
1 parent ce19730 commit e289fab

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ lint-types = [
8181
{ cmd = "uv run mypy --namespace-packages --check-untyped-defs ."},
8282
]
8383
run-bench = "uv run python scripts/run_bench.py"
84-
test = "uv run pytest -s 'tests/nexus/test_workflow_caller_cancellation_types.py::test_cancellation_type[WAIT_COMPLETED]' 'tests/nexus/test_workflow_caller_cancellation_types_when_cancel_handler_fails.py::test_cancellation_type[WAIT_COMPLETED]'"
84+
test = "uv run pytest -s 'tests/nexus/test_workflow_caller_cancellation_types.py::test_print_history'"
8585

8686

8787
[tool.pytest.ini_options]

tests/helpers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ async def print_history(handle: WorkflowHandle):
297297
i = 1
298298
async for evt in handle.fetch_history_events():
299299
event = EventType.Name(evt.event_type).removeprefix("EVENT_TYPE_")
300-
print(f"{i:2}: {event}")
300+
print(f"{i:2}: {evt.event_time.ToDatetime()} {event}")
301301
i += 1
302302

303303

tests/nexus/test_workflow_caller_cancellation_types.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from temporalio.common import WorkflowIDConflictPolicy
2222
from temporalio.testing import WorkflowEnvironment
2323
from temporalio.worker import Worker
24-
from tests.helpers import print_interleaved_histories
24+
from tests.helpers import print_history, print_interleaved_histories
2525
from tests.helpers.nexus import create_nexus_endpoint, make_nexus_endpoint_name
2626

2727

@@ -513,3 +513,31 @@ def _event_time(
513513
)
514514
previous_expected_event_type_name = expected_event_type_name
515515
previous_expected_handle = expected_handle
516+
517+
518+
@workflow.defn(sandboxed=False)
519+
class PrintHistoryWorkflow:
520+
@workflow.run
521+
async def run(self) -> None:
522+
await workflow.sleep(1)
523+
524+
525+
async def test_print_history(env: WorkflowEnvironment):
526+
if env.supports_time_skipping:
527+
pytest.skip("Nexus tests don't work with time-skipping server")
528+
529+
client = env.client
530+
531+
async with Worker(
532+
client,
533+
task_queue=str(uuid.uuid4()),
534+
workflows=[PrintHistoryWorkflow],
535+
) as worker:
536+
print_history_wf = await client.start_workflow(
537+
PrintHistoryWorkflow.run,
538+
id="print-history-wf-1",
539+
task_queue=worker.task_queue,
540+
)
541+
await print_history_wf.result()
542+
print()
543+
await print_history(print_history_wf)

0 commit comments

Comments
 (0)