From 8c94f4441d332c4b181dab22cfe37da4941757d5 Mon Sep 17 00:00:00 2001 From: Johan Date: Thu, 13 Nov 2025 18:04:13 +0100 Subject: [PATCH 1/2] adding pascal case to status --- temporalio/client.py | 11 +++++++++++ tests/test_client.py | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/temporalio/client.py b/temporalio/client.py index 770a51392..ce227d0a5 100644 --- a/temporalio/client.py +++ b/temporalio/client.py @@ -3147,6 +3147,17 @@ class WorkflowExecutionStatus(IntEnum): temporalio.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_TIMED_OUT ) + @property + def to_pascal_case(self) -> str: + """Convert WorkflowExecutionStatus enum name to Temporal search attribute format. + + Returns: + Formatted string for ExecutionStatus search attribute + """ + # Convert "TIMED_OUT" -> "TimedOut", "CONTINUED_AS_NEW" -> "ContinuedAsNew", etc. + parts = self.name.split("_") + return "".join(part.capitalize() for part in parts) + @dataclass class WorkflowExecutionCount: diff --git a/tests/test_client.py b/tests/test_client.py index 63dec2810..d2fa0a689 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -410,6 +410,26 @@ async def test_query_rejected(client: Client, worker: ExternalWorker): assert err.value.status == WorkflowExecutionStatus.COMPLETED +def test_workflow_execution_status_search_attribute_value(): + """Test that WorkflowExecutionStatus.to_pascal_case converts to PascalCase correctly.""" + test_cases = [ + (WorkflowExecutionStatus.RUNNING, "Running"), + (WorkflowExecutionStatus.COMPLETED, "Completed"), + (WorkflowExecutionStatus.FAILED, "Failed"), + (WorkflowExecutionStatus.CANCELED, "Canceled"), + (WorkflowExecutionStatus.TERMINATED, "Terminated"), + (WorkflowExecutionStatus.TIMED_OUT, "TimedOut"), + (WorkflowExecutionStatus.CONTINUED_AS_NEW, "ContinuedAsNew"), + ] + + for status, expected in test_cases: + actual = status.to_pascal_case + assert actual == expected, ( + f"WorkflowExecutionStatus.{status.name}.to_pascal_case " + f"returned '{actual}', expected '{expected}'" + ) + + async def test_signal(client: Client, worker: ExternalWorker): handle = await client.start_workflow( "kitchen_sink", From 775a0210853a7c204a0b1ca3079122080b89cd68 Mon Sep 17 00:00:00 2001 From: Johan Date: Thu, 13 Nov 2025 18:13:07 +0100 Subject: [PATCH 2/2] simplify --- temporalio/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/temporalio/client.py b/temporalio/client.py index ce227d0a5..593cef4a4 100644 --- a/temporalio/client.py +++ b/temporalio/client.py @@ -3155,8 +3155,8 @@ def to_pascal_case(self) -> str: Formatted string for ExecutionStatus search attribute """ # Convert "TIMED_OUT" -> "TimedOut", "CONTINUED_AS_NEW" -> "ContinuedAsNew", etc. - parts = self.name.split("_") - return "".join(part.capitalize() for part in parts) + return "".join(word.capitalize() for word in self.name.split("_")) + @dataclass