Fix missing dynamodb key status code to fix has_item. Closes #20
This commit is contained in:
parent
4c8244b755
commit
755fe6563b
@ -195,7 +195,7 @@ class DynamoHandler(BaseResponse):
|
|||||||
return dynamo_json_dump(item_dict)
|
return dynamo_json_dump(item_dict)
|
||||||
else:
|
else:
|
||||||
er = 'com.amazonaws.dynamodb.v20111205#ResourceNotFoundException'
|
er = 'com.amazonaws.dynamodb.v20111205#ResourceNotFoundException'
|
||||||
return self.error(er)
|
return self.error(er, status=404)
|
||||||
|
|
||||||
def batch_get_item(self):
|
def batch_get_item(self):
|
||||||
table_batches = self.body['RequestItems']
|
table_batches = self.body['RequestItems']
|
||||||
|
@ -6,6 +6,7 @@ from moto import mock_dynamodb
|
|||||||
from moto.dynamodb import dynamodb_backend
|
from moto.dynamodb import dynamodb_backend
|
||||||
|
|
||||||
from boto.dynamodb import condition
|
from boto.dynamodb import condition
|
||||||
|
from boto.dynamodb.exceptions import DynamoDBKeyNotFoundError
|
||||||
from boto.exception import DynamoDBResponseError
|
from boto.exception import DynamoDBResponseError
|
||||||
|
|
||||||
|
|
||||||
@ -101,6 +102,8 @@ def test_item_add_and_describe_and_update():
|
|||||||
)
|
)
|
||||||
item.put()
|
item.put()
|
||||||
|
|
||||||
|
table.has_item("LOLCat Forum", "Check this out!").should.equal(True)
|
||||||
|
|
||||||
returned_item = table.get_item(
|
returned_item = table.get_item(
|
||||||
hash_key='LOLCat Forum',
|
hash_key='LOLCat Forum',
|
||||||
range_key='Check this out!',
|
range_key='Check this out!',
|
||||||
@ -150,7 +153,8 @@ def test_get_missing_item():
|
|||||||
table.get_item.when.called_with(
|
table.get_item.when.called_with(
|
||||||
hash_key='tester',
|
hash_key='tester',
|
||||||
range_key='other',
|
range_key='other',
|
||||||
).should.throw(DynamoDBResponseError)
|
).should.throw(DynamoDBKeyNotFoundError)
|
||||||
|
table.has_item("foobar").should.equal(False)
|
||||||
|
|
||||||
|
|
||||||
@mock_dynamodb
|
@mock_dynamodb
|
||||||
@ -163,7 +167,7 @@ def test_get_item_with_undeclared_table():
|
|||||||
'HashKeyElement': {'S': 'tester'},
|
'HashKeyElement': {'S': 'tester'},
|
||||||
'RangeKeyElement': {'S': 'test-range'},
|
'RangeKeyElement': {'S': 'test-range'},
|
||||||
},
|
},
|
||||||
).should.throw(DynamoDBResponseError)
|
).should.throw(DynamoDBKeyNotFoundError)
|
||||||
|
|
||||||
|
|
||||||
@mock_dynamodb
|
@mock_dynamodb
|
||||||
|
@ -6,6 +6,7 @@ from moto import mock_dynamodb
|
|||||||
from moto.dynamodb import dynamodb_backend
|
from moto.dynamodb import dynamodb_backend
|
||||||
|
|
||||||
from boto.dynamodb import condition
|
from boto.dynamodb import condition
|
||||||
|
from boto.dynamodb.exceptions import DynamoDBKeyNotFoundError
|
||||||
from boto.exception import DynamoDBResponseError
|
from boto.exception import DynamoDBResponseError
|
||||||
|
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ def test_get_missing_item():
|
|||||||
|
|
||||||
table.get_item.when.called_with(
|
table.get_item.when.called_with(
|
||||||
hash_key='tester',
|
hash_key='tester',
|
||||||
).should.throw(DynamoDBResponseError)
|
).should.throw(DynamoDBKeyNotFoundError)
|
||||||
|
|
||||||
|
|
||||||
@mock_dynamodb
|
@mock_dynamodb
|
||||||
@ -149,7 +150,7 @@ def test_get_item_with_undeclared_table():
|
|||||||
key={
|
key={
|
||||||
'HashKeyElement': {'S': 'tester'},
|
'HashKeyElement': {'S': 'tester'},
|
||||||
},
|
},
|
||||||
).should.throw(DynamoDBResponseError)
|
).should.throw(DynamoDBKeyNotFoundError)
|
||||||
|
|
||||||
|
|
||||||
@mock_dynamodb
|
@mock_dynamodb
|
||||||
|
Loading…
Reference in New Issue
Block a user