Skip to content

Bug/parsing issues #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 21, 2020
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
7 changes: 4 additions & 3 deletions azure/durable_functions/tasks/task_utilities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import json

from ..models.history import HistoryEventType

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

if event_type == HistoryEventType.EventRaised:
return directive_result["Input"]
return json.loads(directive_result["Input"])
if event_type == HistoryEventType.SubOrchestrationInstanceCreated:
return directive_result["Result"]
return json.loads(directive_result["Result"])
if event_type == HistoryEventType.TaskCompleted:
return directive_result["Result"]
return json.loads(directive_result["Result"])
return None


Expand Down
12 changes: 6 additions & 6 deletions tests/orchestrator/test_sequential_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_initial_orchestration_state():

def test_tokyo_state():
context_builder = ContextBuilder('test_simple_function')
add_hello_completed_events(context_builder, 0, 'Hello Tokyo!')
add_hello_completed_events(context_builder, 0, "\"Hello Tokyo!\"")
result = get_orchestration_state_result(context_builder, generator_function)
expected_state = base_expected_state()
add_hello_action(expected_state, 'Tokyo')
Expand All @@ -77,8 +77,8 @@ def test_failed_tokyo_state():

def test_tokyo_and_seattle_state():
context_builder = ContextBuilder('test_simple_function')
add_hello_completed_events(context_builder, 0, 'Hello Tokyo!')
add_hello_completed_events(context_builder, 1, 'Hello Seattle!')
add_hello_completed_events(context_builder, 0, "\"Hello Tokyo!\"")
add_hello_completed_events(context_builder, 1, "\"Hello Seattle!\"")
result = get_orchestration_state_result(context_builder, generator_function)
expected_state = base_expected_state()
add_hello_action(expected_state, 'Tokyo')
Expand All @@ -90,9 +90,9 @@ def test_tokyo_and_seattle_state():

def test_tokyo_and_seattle_and_london_state():
context_builder = ContextBuilder('test_simple_function')
add_hello_completed_events(context_builder, 0, 'Hello Tokyo!')
add_hello_completed_events(context_builder, 1, 'Hello Seattle!')
add_hello_completed_events(context_builder, 2, 'Hello London!')
add_hello_completed_events(context_builder, 0, "\"Hello Tokyo!\"")
add_hello_completed_events(context_builder, 1, "\"Hello Seattle!\"")
add_hello_completed_events(context_builder, 2, "\"Hello London!\"")
result = get_orchestration_state_result(context_builder, generator_function)
expected_state = base_expected_state(['Hello Tokyo!', 'Hello Seattle!', 'Hello London!'])
add_hello_action(expected_state, 'Tokyo')
Expand Down
17 changes: 16 additions & 1 deletion tests/orchestrator/test_sequential_orchestrator_with_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_initial_orchestration_state():

def test_tokyo_state():
context_builder = ContextBuilder('test_simple_function')
add_hello_completed_events(context_builder, 0, 'Hello Tokyo!')
add_hello_completed_events(context_builder, 0, "\"Hello Tokyo!\"")
result = get_orchestration_state_result(context_builder, generator_function)
expected_state = base_expected_state()
add_hello_action(expected_state, 'Tokyo')
Expand Down Expand Up @@ -131,6 +131,21 @@ def test_failed_tokyo_with_failed_retry_timer_added():
assert_orchestration_state_equals(expected, result)


def test_successful_tokyo_with_failed_retry_timer_added():
failed_reason = 'Reasons'
failed_details = 'Stuff and Things'
context_builder = ContextBuilder('test_simple_function')
add_hello_failed_events(context_builder, 0, failed_reason, failed_details)
add_retry_timer_events(context_builder, 1)
add_hello_completed_events(context_builder, 2, "\"Hello Tokyo!\"")
result = get_orchestration_state_result(context_builder, generator_function)
expected_state = base_expected_state()
add_hello_action(expected_state, 'Tokyo')
add_hello_action(expected_state, 'Seattle')
expected = expected_state.to_json()
assert_orchestration_state_equals(expected, result)


def test_failed_tokyo_hit_max_attempts():
failed_reason = 'Reasons'
failed_details = 'Stuff and Things'
Expand Down
Empty file removed tests/tasks/__init__.py
Empty file.
115 changes: 0 additions & 115 deletions tests/tasks/test_call_activity.py

This file was deleted.