diff --git a/moto/swf/models/__init__.py b/moto/swf/models/__init__.py index 4d70fbd0e..88e362f4e 100644 --- a/moto/swf/models/__init__.py +++ b/moto/swf/models/__init__.py @@ -243,7 +243,7 @@ class SWFBackend(BaseBackend): raise SWFValidationException("Invalid token") # decision task found, but WorflowExecution is CLOSED wfe = decision_task.workflow_execution - if wfe.execution_status != "OPEN": + if not wfe.open: raise SWFUnknownResourceFault( "execution", "WorkflowExecution=[workflowId={0}, runId={1}]".format( @@ -331,7 +331,7 @@ class SWFBackend(BaseBackend): raise SWFValidationException("Invalid token") # activity task found, but WorflowExecution is CLOSED wfe = activity_task.workflow_execution - if wfe.execution_status != "OPEN": + if not wfe.open: raise SWFUnknownResourceFault( "execution", "WorkflowExecution=[workflowId={0}, runId={1}]".format( diff --git a/moto/swf/models/domain.py b/moto/swf/models/domain.py index 55bf1b8e8..824782c59 100644 --- a/moto/swf/models/domain.py +++ b/moto/swf/models/domain.py @@ -83,7 +83,7 @@ class Domain(object): if w.workflow_id == workflow_id and w.run_id == run_id] else: _all = [w for w in self.workflow_executions - if w.workflow_id == workflow_id and w.execution_status == "OPEN"] + if w.workflow_id == workflow_id and w.open] # reduce wfe = _all[0] if _all else None # raise if closed / none diff --git a/moto/swf/models/workflow_execution.py b/moto/swf/models/workflow_execution.py index 3645b645d..aee678a1d 100644 --- a/moto/swf/models/workflow_execution.py +++ b/moto/swf/models/workflow_execution.py @@ -523,7 +523,7 @@ class WorkflowExecution(object): self.close_cause = "OPERATOR_INITIATED" def has_timedout(self): - if self.execution_status != "OPEN" or not self.start_timestamp: + if not self.open or not self.start_timestamp: return False # TODO: handle the "NONE" case start_to_close_timeout = self.start_timestamp + \ @@ -535,3 +535,7 @@ class WorkflowExecution(object): self.execution_status = "CLOSED" self.close_status = "TIMED_OUT" self.timeout_type = "START_TO_CLOSE" + + @property + def open(self): + return self.execution_status == "OPEN"