Skip to content

Commit 088751f

Browse files
Merge pull request #25 from scgbear/bug/parsing-issues
Bug/parsing issues
2 parents 567fbb7 + 02e08bd commit 088751f

File tree

5 files changed

+26
-125
lines changed

5 files changed

+26
-125
lines changed

azure/durable_functions/tasks/task_utilities.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import json
23

34
from ..models.history import HistoryEventType
45

@@ -16,11 +17,11 @@ def parse_history_event(directive_result):
1617
raise ValueError("EventType is not found in task object")
1718

1819
if event_type == HistoryEventType.EventRaised:
19-
return directive_result["Input"]
20+
return json.loads(directive_result["Input"])
2021
if event_type == HistoryEventType.SubOrchestrationInstanceCreated:
21-
return directive_result["Result"]
22+
return json.loads(directive_result["Result"])
2223
if event_type == HistoryEventType.TaskCompleted:
23-
return directive_result["Result"]
24+
return json.loads(directive_result["Result"])
2425
return None
2526

2627

tests/orchestrator/test_sequential_orchestrator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_initial_orchestration_state():
5353

5454
def test_tokyo_state():
5555
context_builder = ContextBuilder('test_simple_function')
56-
add_hello_completed_events(context_builder, 0, 'Hello Tokyo!')
56+
add_hello_completed_events(context_builder, 0, "\"Hello Tokyo!\"")
5757
result = get_orchestration_state_result(context_builder, generator_function)
5858
expected_state = base_expected_state()
5959
add_hello_action(expected_state, 'Tokyo')
@@ -77,8 +77,8 @@ def test_failed_tokyo_state():
7777

7878
def test_tokyo_and_seattle_state():
7979
context_builder = ContextBuilder('test_simple_function')
80-
add_hello_completed_events(context_builder, 0, 'Hello Tokyo!')
81-
add_hello_completed_events(context_builder, 1, 'Hello Seattle!')
80+
add_hello_completed_events(context_builder, 0, "\"Hello Tokyo!\"")
81+
add_hello_completed_events(context_builder, 1, "\"Hello Seattle!\"")
8282
result = get_orchestration_state_result(context_builder, generator_function)
8383
expected_state = base_expected_state()
8484
add_hello_action(expected_state, 'Tokyo')
@@ -90,9 +90,9 @@ def test_tokyo_and_seattle_state():
9090

9191
def test_tokyo_and_seattle_and_london_state():
9292
context_builder = ContextBuilder('test_simple_function')
93-
add_hello_completed_events(context_builder, 0, 'Hello Tokyo!')
94-
add_hello_completed_events(context_builder, 1, 'Hello Seattle!')
95-
add_hello_completed_events(context_builder, 2, 'Hello London!')
93+
add_hello_completed_events(context_builder, 0, "\"Hello Tokyo!\"")
94+
add_hello_completed_events(context_builder, 1, "\"Hello Seattle!\"")
95+
add_hello_completed_events(context_builder, 2, "\"Hello London!\"")
9696
result = get_orchestration_state_result(context_builder, generator_function)
9797
expected_state = base_expected_state(['Hello Tokyo!', 'Hello Seattle!', 'Hello London!'])
9898
add_hello_action(expected_state, 'Tokyo')

tests/orchestrator/test_sequential_orchestrator_with_retry.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_initial_orchestration_state():
6868

6969
def test_tokyo_state():
7070
context_builder = ContextBuilder('test_simple_function')
71-
add_hello_completed_events(context_builder, 0, 'Hello Tokyo!')
71+
add_hello_completed_events(context_builder, 0, "\"Hello Tokyo!\"")
7272
result = get_orchestration_state_result(context_builder, generator_function)
7373
expected_state = base_expected_state()
7474
add_hello_action(expected_state, 'Tokyo')
@@ -131,6 +131,21 @@ def test_failed_tokyo_with_failed_retry_timer_added():
131131
assert_orchestration_state_equals(expected, result)
132132

133133

134+
def test_successful_tokyo_with_failed_retry_timer_added():
135+
failed_reason = 'Reasons'
136+
failed_details = 'Stuff and Things'
137+
context_builder = ContextBuilder('test_simple_function')
138+
add_hello_failed_events(context_builder, 0, failed_reason, failed_details)
139+
add_retry_timer_events(context_builder, 1)
140+
add_hello_completed_events(context_builder, 2, "\"Hello Tokyo!\"")
141+
result = get_orchestration_state_result(context_builder, generator_function)
142+
expected_state = base_expected_state()
143+
add_hello_action(expected_state, 'Tokyo')
144+
add_hello_action(expected_state, 'Seattle')
145+
expected = expected_state.to_json()
146+
assert_orchestration_state_equals(expected, result)
147+
148+
134149
def test_failed_tokyo_hit_max_attempts():
135150
failed_reason = 'Reasons'
136151
failed_details = 'Stuff and Things'

tests/tasks/__init__.py

Whitespace-only changes.

tests/tasks/test_call_activity.py

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)