Change to JsonRESTError

This commit is contained in:
gruebel 2019-11-21 22:34:05 +01:00
parent 158db1f5d6
commit cd633f8bc5
2 changed files with 11 additions and 14 deletions

View File

@ -1,15 +1,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from moto.core.exceptions import JsonRESTError
import json
from werkzeug.exceptions import BadRequest
class InvalidInputError(BadRequest): class InvalidInputException(JsonRESTError):
code = 400
def __init__(self): def __init__(self):
super(InvalidInputError, self).__init__() super(InvalidInputException, self).__init__(
self.description = json.dumps( "InvalidInputException",
{ "You provided a value that does not match the required pattern.",
"message": "You provided a value that does not match the required pattern.",
"__type": "InvalidInputException",
}
) )

View File

@ -8,7 +8,7 @@ from moto.core import BaseBackend, BaseModel
from moto.core.exceptions import RESTError from moto.core.exceptions import RESTError
from moto.core.utils import unix_time from moto.core.utils import unix_time
from moto.organizations import utils from moto.organizations import utils
from moto.organizations.exceptions import InvalidInputError from moto.organizations.exceptions import InvalidInputException
class FakeOrganization(BaseModel): class FakeOrganization(BaseModel):
@ -448,7 +448,7 @@ class OrganizationsBackend(BaseBackend):
account = next((a for a in self.accounts if a.id == kwargs["ResourceId"]), None) account = next((a for a in self.accounts if a.id == kwargs["ResourceId"]), None)
if account is None: if account is None:
raise InvalidInputError raise InvalidInputException
new_tags = {tag["Key"]: tag["Value"] for tag in kwargs["Tags"]} new_tags = {tag["Key"]: tag["Value"] for tag in kwargs["Tags"]}
account.tags.update(new_tags) account.tags.update(new_tags)
@ -457,7 +457,7 @@ class OrganizationsBackend(BaseBackend):
account = next((a for a in self.accounts if a.id == kwargs["ResourceId"]), None) account = next((a for a in self.accounts if a.id == kwargs["ResourceId"]), None)
if account is None: if account is None:
raise InvalidInputError raise InvalidInputException
tags = [{"Key": key, "Value": value} for key, value in account.tags.items()] tags = [{"Key": key, "Value": value} for key, value in account.tags.items()]
return dict(Tags=tags) return dict(Tags=tags)
@ -466,7 +466,7 @@ class OrganizationsBackend(BaseBackend):
account = next((a for a in self.accounts if a.id == kwargs["ResourceId"]), None) account = next((a for a in self.accounts if a.id == kwargs["ResourceId"]), None)
if account is None: if account is None:
raise InvalidInputError raise InvalidInputException
for key in kwargs["TagKeys"]: for key in kwargs["TagKeys"]:
account.tags.pop(key, None) account.tags.pop(key, None)