Address SFN.Client.exceptions.ExecutionAlreadyExists Not implemented (#3263)

* Add check for existing execution, fix issue with make init

* Remove f-string usage

* Remove fstring usage in test

* Pin black and run formatting on test_stepfunction

* Reverse changes made by black 20.8b1
This commit is contained in:
Ciaran Evans 2020-08-27 08:22:44 +01:00 committed by GitHub
commit 3b06ce689e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 1 deletions

View file

@ -8,6 +8,7 @@ from moto.core.utils import iso_8601_datetime_without_milliseconds
from moto.sts.models import ACCOUNT_ID
from uuid import uuid4
from .exceptions import (
ExecutionAlreadyExists,
ExecutionDoesNotExist,
InvalidArn,
InvalidName,
@ -205,6 +206,7 @@ class StepFunctionBackend(BaseBackend):
def start_execution(self, state_machine_arn, name=None):
state_machine_name = self.describe_state_machine(state_machine_arn).name
self._ensure_execution_name_doesnt_exist(name)
execution = Execution(
region_name=self.region_name,
account_id=self._get_account_id(),
@ -278,6 +280,13 @@ class StepFunctionBackend(BaseBackend):
if not arn or not match:
raise InvalidArn(invalid_msg)
def _ensure_execution_name_doesnt_exist(self, name):
for execution in self.executions:
if execution.name == name:
raise ExecutionAlreadyExists(
"Execution Already Exists: '" + execution.execution_arn + "'"
)
def _get_account_id(self):
return ACCOUNT_ID