Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ async def wait_for_completion_or_create_check_status_response(
lambda: self._create_http_response(500, status.to_json()),
}

result = switch_statement.get(OrchestrationRuntimeStatus(status.runtime_status))
result = switch_statement.get(status.runtime_status)
if result:
return result()

Expand Down
14 changes: 9 additions & 5 deletions azure/durable_functions/models/DurableOrchestrationStatus.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime
from dateutil.parser import parse as dt_parse
from typing import Any, List, Dict, Optional, Union

from .OrchestrationRuntimeStatus import OrchestrationRuntimeStatus
from .utils.json_utils import add_attrib, add_datetime_attrib


Expand All @@ -15,7 +15,8 @@ class DurableOrchestrationStatus:
def __init__(self, name: Optional[str] = None, instanceId: Optional[str] = None,
createdTime: Optional[str] = None, lastUpdatedTime: Optional[str] = None,
input: Optional[Any] = None, output: Optional[Any] = None,
runtimeStatus: Optional[str] = None, customStatus: Optional[Any] = None,
runtimeStatus: Optional[OrchestrationRuntimeStatus] = None,
customStatus: Optional[Any] = None,
history: Optional[List[Any]] = None,
**kwargs):
self._name: Optional[str] = name
Expand All @@ -26,7 +27,9 @@ def __init__(self, name: Optional[str] = None, instanceId: Optional[str] = None,
if lastUpdatedTime is not None else None
self._input: Any = input
self._output: Any = output
self._runtime_status: Optional[str] = runtimeStatus # TODO: GH issue 178
self._runtime_status: Optional[OrchestrationRuntimeStatus] = runtimeStatus
if runtimeStatus is not None:
self._runtime_status = OrchestrationRuntimeStatus(runtimeStatus)
self._custom_status: Any = customStatus
self._history: Optional[List[Any]] = history
if kwargs is not None:
Expand Down Expand Up @@ -82,7 +85,8 @@ def to_json(self) -> Dict[str, Union[int, str]]:
add_datetime_attrib(json, self, 'last_updated_time', 'lastUpdatedTime')
add_attrib(json, self, 'output')
add_attrib(json, self, 'input_', 'input')
add_attrib(json, self, 'runtime_status', 'runtimeStatus')
if self.runtime_status is not None:
json["runtimeStatus"] = self.runtime_status.name
add_attrib(json, self, 'custom_status', 'customStatus')
add_attrib(json, self, 'history')
return json
Expand Down Expand Up @@ -129,7 +133,7 @@ def output(self) -> Any:
return self._output

@property
def runtime_status(self) -> Optional[str]:
def runtime_status(self) -> Optional[OrchestrationRuntimeStatus]:
"""Get the runtime status of the orchestration instance."""
return self._runtime_status

Expand Down
4 changes: 2 additions & 2 deletions tests/models/test_DurableOrchestrationClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ async def test_get_202_get_status_success(binding_string):

result = await client.get_status(TEST_INSTANCE_ID)
assert result is not None
assert result.runtime_status == "Running"
assert result.runtime_status.name == "Running"


@pytest.mark.asyncio
Expand All @@ -161,7 +161,7 @@ async def test_get_200_get_status_success(binding_string):

result = await client.get_status(TEST_INSTANCE_ID)
assert result is not None
assert result.runtime_status == "Completed"
assert result.runtime_status.name == "Completed"


@pytest.mark.asyncio
Expand Down
3 changes: 2 additions & 1 deletion tests/models/test_DurableOrchestrationStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from azure.durable_functions.constants import DATETIME_STRING_FORMAT
from azure.durable_functions.models.DurableOrchestrationStatus import DurableOrchestrationStatus
from azure.durable_functions.models.OrchestrationRuntimeStatus import OrchestrationRuntimeStatus
from azure.durable_functions.models.history import HistoryEventType

TEST_NAME = 'what ever I want it to be'
Expand Down Expand Up @@ -38,7 +39,7 @@ def test_all_the_args():

result = DurableOrchestrationStatus.from_json(response)

assert result.runtime_status == TEST_RUNTIME_STATUS
assert result.runtime_status.name == TEST_RUNTIME_STATUS
assert result.custom_status == TEST_CUSTOM_STATUS
assert result.instance_id == TEST_INSTANCE_ID
assert result.output == TEST_OUTPUT
Expand Down