From 31b01d27cfbec35454aae16ee0555b3a4c8f2721 Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Sun, 26 Oct 2014 20:55:11 -0400 Subject: [PATCH 1/3] Some fixes for dynamodb and python 3. --- .travis.yml | 3 +-- moto/dynamodb/models.py | 3 +++ moto/dynamodb/responses.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d6242615..f6565c95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,13 +5,12 @@ python: env: matrix: - BOTO_VERSION=2.34.0 - - BOTO_VERSION=2.32.1 - BOTO_VERSION=2.25.0 - BOTO_VERSION=2.7 matrix: include: - python: "3.3" - env: BOTO_VERSION=2.32.1 + env: BOTO_VERSION=2.32.4 install: - pip install boto==$BOTO_VERSION - pip install . diff --git a/moto/dynamodb/models.py b/moto/dynamodb/models.py index 27a2cea5..4251445d 100644 --- a/moto/dynamodb/models.py +++ b/moto/dynamodb/models.py @@ -153,6 +153,9 @@ class Table(object): def __nonzero__(self): return True + def __bool__(self): + return self.__nonzero__() + def put_item(self, item_attrs): hash_value = DynamoType(item_attrs.get(self.hash_key_attr)) if self.has_range_key: diff --git a/moto/dynamodb/responses.py b/moto/dynamodb/responses.py index 2e166529..53365766 100644 --- a/moto/dynamodb/responses.py +++ b/moto/dynamodb/responses.py @@ -159,8 +159,8 @@ class DynamoHandler(BaseResponse): for table_name, table_requests in table_batches.items(): for table_request in table_requests: - request_type = table_request.keys()[0] - request = table_request.values()[0] + request_type = list(table_request)[0] + request = list(table_request.values())[0] if request_type == 'PutRequest': item = request['Item'] From 56ee4fa555adc1de84714541b157862b0e4abdcc Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Sun, 26 Oct 2014 20:59:11 -0400 Subject: [PATCH 2/3] Fix boto version. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f6565c95..c52276b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ env: matrix: include: - python: "3.3" - env: BOTO_VERSION=2.32.4 + env: BOTO_VERSION=2.34.0 install: - pip install boto==$BOTO_VERSION - pip install . From 4bfbf3bbf3cc6416b9d31b5392bfcb7f3eab7427 Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Sun, 26 Oct 2014 21:11:03 -0400 Subject: [PATCH 3/3] Python3 fixes for dynamodb2. --- moto/dynamodb2/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/moto/dynamodb2/models.py b/moto/dynamodb2/models.py index 6f849afa..1da4e577 100644 --- a/moto/dynamodb2/models.py +++ b/moto/dynamodb2/models.py @@ -31,8 +31,8 @@ class DynamoType(object): """ def __init__(self, type_as_dict): - self.type = type_as_dict.keys()[0] - self.value = type_as_dict.values()[0] + self.type = list(type_as_dict)[0] + self.value = list(type_as_dict.values())[0] def __hash__(self): return hash((self.type, self.value)) @@ -173,6 +173,9 @@ class Table(object): def __nonzero__(self): return True + def __bool__(self): + return self.__nonzero__() + @property def has_range_key(self): return self.range_key_attr is not None