@@ -1910,6 +1910,10 @@ def my_signal(self, value: str) -> None:
19101910 self ._last_signal = value
19111911 workflow .logger .info (f"Signal: { value } " )
19121912
1913+ @workflow .update
1914+ def my_update (self , value : str ) -> None :
1915+ workflow .logger .info (f"Update: { value } " )
1916+
19131917 @workflow .query
19141918 def last_signal (self ) -> str :
19151919 return self ._last_signal
@@ -1957,14 +1961,22 @@ async def test_workflow_logging(client: Client, env: WorkflowEnvironment):
19571961 id = f"workflow-{ uuid .uuid4 ()} " ,
19581962 task_queue = worker .task_queue ,
19591963 )
1960- # Send a couple signals
1964+ # Send some signals and updates
19611965 await handle .signal (LoggingWorkflow .my_signal , "signal 1" )
19621966 await handle .signal (LoggingWorkflow .my_signal , "signal 2" )
1967+ await handle .execute_update (
1968+ LoggingWorkflow .my_update , "update 1" , id = "update-1"
1969+ )
1970+ await handle .execute_update (
1971+ LoggingWorkflow .my_update , "update 2" , id = "update-2"
1972+ )
19631973 assert "signal 2" == await handle .query (LoggingWorkflow .last_signal )
19641974
1965- # Confirm two logs happened
1975+ # Confirm logs were produced
19661976 assert capturer .find_log ("Signal: signal 1 ({'attempt':" )
19671977 assert capturer .find_log ("Signal: signal 2" )
1978+ assert capturer .find_log ("Update: update 1" )
1979+ assert capturer .find_log ("Update: update 2" )
19681980 assert not capturer .find_log ("Signal: signal 3" )
19691981 # Also make sure it has some workflow info and correct funcName
19701982 record = capturer .find_log ("Signal: signal 1" )
@@ -1976,6 +1988,15 @@ async def test_workflow_logging(client: Client, env: WorkflowEnvironment):
19761988 )
19771989 # Since we enabled full info, make sure it's there
19781990 assert isinstance (record .__dict__ ["workflow_info" ], workflow .Info )
1991+ # Check the log emitted by the update execution.
1992+ record = capturer .find_log ("Update: update 1" )
1993+ assert (
1994+ record
1995+ and record .__dict__ ["temporal_workflow" ]["update_id" ] == "update-1"
1996+ and record .__dict__ ["temporal_workflow" ]["update_name" ] == "my_update"
1997+ and "'update_id': 'update-1'" in record .message
1998+ and "'update_name': 'my_update'" in record .message
1999+ )
19792000
19802001 # Clear queue and start a new one with more signals
19812002 capturer .log_queue .queue .clear ()
@@ -1985,7 +2006,7 @@ async def test_workflow_logging(client: Client, env: WorkflowEnvironment):
19852006 task_queue = worker .task_queue ,
19862007 max_cached_workflows = 0 ,
19872008 ) as worker :
1988- # Send a couple signals
2009+ # Send signals and updates
19892010 await handle .signal (LoggingWorkflow .my_signal , "signal 3" )
19902011 await handle .signal (LoggingWorkflow .my_signal , "finish" )
19912012 await handle .result ()
0 commit comments