Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion azure/durable_functions/models/OrchestratorState.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def to_json(self) -> Dict[str, Any]:
json_dict = {}
add_attrib(json_dict, self, '_is_done', 'isDone')
self._add_actions(json_dict)
if self._output:
if not (self._output is None):
json_dict['output'] = self._output
if self._error:
json_dict['error'] = self._error
Expand Down
30 changes: 30 additions & 0 deletions tests/orchestrator/test_serialization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from tests.test_utils.ContextBuilder import ContextBuilder
from .orchestrator_test_utils \
import get_orchestration_state_result, assert_orchestration_state_equals, assert_valid_schema
from azure.durable_functions.models.OrchestratorState import OrchestratorState

def base_expected_state(output=None) -> OrchestratorState:
return OrchestratorState(is_done=False, actions=[], output=output)

def generator_function(context):
return False

def test_serialization_of_False():
"""Test that an orchestrator can return False."""

context_builder = ContextBuilder("serialize False")

result = get_orchestration_state_result(
context_builder, generator_function)

expected_state = base_expected_state(output=False)

expected_state._is_done = True
expected = expected_state.to_json()

# Since we're essentially testing the `to_json` functionality,
# we explicitely ensure that the output is set
expected["output"] = False

assert_valid_schema(result)
assert_orchestration_state_equals(expected, result)