From 31d30c8ea47e475c99500608a07c6869f2684208 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 10 Sep 2015 11:31:46 +0200 Subject: [PATCH] return the correct response tryin to re-create a table --- moto/dynamodb2/models.py | 2 ++ moto/dynamodb2/responses.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/moto/dynamodb2/models.py b/moto/dynamodb2/models.py index 3f5a71f7a..e7277ee6b 100644 --- a/moto/dynamodb2/models.py +++ b/moto/dynamodb2/models.py @@ -336,6 +336,8 @@ class DynamoDBBackend(BaseBackend): self.tables = OrderedDict() def create_table(self, name, **params): + if name in self.tables: + return None table = Table(name, **params) self.tables[name] = table return table diff --git a/moto/dynamodb2/responses.py b/moto/dynamodb2/responses.py index 5f4372f77..57d06bbf3 100644 --- a/moto/dynamodb2/responses.py +++ b/moto/dynamodb2/responses.py @@ -100,12 +100,17 @@ class DynamoHandler(BaseResponse): attr = body["AttributeDefinitions"] # getting the indexes global_indexes = body.get("GlobalSecondaryIndexes", []) + table = dynamodb_backend2.create_table(table_name, schema=key_schema, throughput=throughput, attr=attr, global_indexes=global_indexes) - return dynamo_json_dump(table.describe) + if table is not None: + return dynamo_json_dump(table.describe) + else: + er = 'com.amazonaws.dynamodb.v20111205#ResourceInUseException' + return self.error(er) def delete_table(self): name = self.body['TableName']