Add checks for *DecisionAttributes within RespondDecisionTaskCompleted

This commit is contained in:
Jean-Baptiste Barth 2015-10-19 09:25:54 +02:00
commit 558b84fb6a
6 changed files with 169 additions and 7 deletions

View file

@ -191,3 +191,42 @@ def test_respond_decision_task_completed_with_invalid_decision_type():
SWFDecisionValidationException,
r"Value 'BadDecisionType' at 'decisions.1.member.decisionType'"
)
@mock_swf
def test_respond_decision_task_completed_with_missing_attributes():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "queue")
task_token = resp["taskToken"]
decisions = [
{
"decisionType": "should trigger even with incorrect decision type",
"startTimerDecisionAttributes": {}
},
]
conn.respond_decision_task_completed.when.called_with(
task_token, decisions=decisions
).should.throw(
SWFDecisionValidationException,
r"Value null at 'decisions.1.member.startTimerDecisionAttributes.timerId' " \
r"failed to satisfy constraint: Member must not be null"
)
@mock_swf
def test_respond_decision_task_completed_with_missing_attributes_totally():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "queue")
task_token = resp["taskToken"]
decisions = [
{ "decisionType": "StartTimer" },
]
conn.respond_decision_task_completed.when.called_with(
task_token, decisions=decisions
).should.throw(
SWFDecisionValidationException,
r"Value null at 'decisions.1.member.startTimerDecisionAttributes.timerId' " \
r"failed to satisfy constraint: Member must not be null"
)

View file

@ -0,0 +1,11 @@
from sure import expect
from moto.swf.utils import decapitalize
def test_decapitalize():
cases = {
"fooBar": "fooBar",
"FooBar": "fooBar",
"FOO BAR": "fOO BAR",
}
for before, after in cases.iteritems():
decapitalize(before).should.equal(after)