From 4e223d23181dcd9da61b09f93b1ac31c842b8e3a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Barth Date: Sun, 11 Oct 2015 22:11:07 +0200 Subject: [PATCH] Fix PollForDecisionTask not respecting requested task list --- moto/swf/models/__init__.py | 5 +++-- tests/test_swf/test_decision_tasks.py | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/moto/swf/models/__init__.py b/moto/swf/models/__init__.py index 16f6c8915..622f38a02 100644 --- a/moto/swf/models/__init__.py +++ b/moto/swf/models/__init__.py @@ -179,8 +179,9 @@ class SWFBackend(BaseBackend): # # TODO: handle long polling (case 2) for decision tasks decision_candidates = [] - for wf_id, wf_execution in domain.workflow_executions.iteritems(): - decision_candidates += wf_execution.scheduled_decision_tasks + for _, wfe in domain.workflow_executions.iteritems(): + if wfe.task_list == task_list: + decision_candidates += wfe.scheduled_decision_tasks if any(decision_candidates): # TODO: handle task priorities (but not supported by boto for now) decision = min(decision_candidates, key=lambda d: d.scheduled_at) diff --git a/tests/test_swf/test_decision_tasks.py b/tests/test_swf/test_decision_tasks.py index 2ff1f7625..313736d7d 100644 --- a/tests/test_swf/test_decision_tasks.py +++ b/tests/test_swf/test_decision_tasks.py @@ -45,6 +45,12 @@ def test_poll_for_decision_task_when_none(): # after waiting 60s when there's no decision to be taken resp.should.equal({"previousStartedEventId": 0, "startedEventId": 0}) +@mock_swf +def test_poll_for_decision_task_on_non_existent_queue(): + conn = setup_workflow() + resp = conn.poll_for_decision_task("test-domain", "non-existent-queue") + resp.should.equal({"previousStartedEventId": 0, "startedEventId": 0}) + @mock_swf def test_poll_for_decision_task_with_reverse_order(): conn = setup_workflow()