From cd633f8bc5a9a96ca1462904fc3a0bcebfcd1433 Mon Sep 17 00:00:00 2001 From: gruebel Date: Thu, 21 Nov 2019 22:34:05 +0100 Subject: [PATCH] Change to JsonRESTError --- moto/organizations/exceptions.py | 17 +++++++---------- moto/organizations/models.py | 8 ++++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/moto/organizations/exceptions.py b/moto/organizations/exceptions.py index 834165bcb..01b98da7e 100644 --- a/moto/organizations/exceptions.py +++ b/moto/organizations/exceptions.py @@ -1,15 +1,12 @@ from __future__ import unicode_literals - -import json -from werkzeug.exceptions import BadRequest +from moto.core.exceptions import JsonRESTError -class InvalidInputError(BadRequest): +class InvalidInputException(JsonRESTError): + code = 400 + def __init__(self): - super(InvalidInputError, self).__init__() - self.description = json.dumps( - { - "message": "You provided a value that does not match the required pattern.", - "__type": "InvalidInputException", - } + super(InvalidInputException, self).__init__( + "InvalidInputException", + "You provided a value that does not match the required pattern.", ) diff --git a/moto/organizations/models.py b/moto/organizations/models.py index 7a9c73e9e..42e4dd00a 100644 --- a/moto/organizations/models.py +++ b/moto/organizations/models.py @@ -8,7 +8,7 @@ from moto.core import BaseBackend, BaseModel from moto.core.exceptions import RESTError from moto.core.utils import unix_time from moto.organizations import utils -from moto.organizations.exceptions import InvalidInputError +from moto.organizations.exceptions import InvalidInputException class FakeOrganization(BaseModel): @@ -448,7 +448,7 @@ class OrganizationsBackend(BaseBackend): account = next((a for a in self.accounts if a.id == kwargs["ResourceId"]), None) if account is None: - raise InvalidInputError + raise InvalidInputException new_tags = {tag["Key"]: tag["Value"] for tag in kwargs["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) if account is None: - raise InvalidInputError + raise InvalidInputException tags = [{"Key": key, "Value": value} for key, value in account.tags.items()] 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) if account is None: - raise InvalidInputError + raise InvalidInputException for key in kwargs["TagKeys"]: account.tags.pop(key, None)