diff --git a/moto/dynamodb2/models.py b/moto/dynamodb2/models.py index 99c965612..7989c6cd5 100644 --- a/moto/dynamodb2/models.py +++ b/moto/dynamodb2/models.py @@ -381,6 +381,7 @@ class DynamoDBBackend(BaseBackend): def get_item(self, table_name, keys): table = self.get_table(table_name) if not table: + raise ValueError() return None hash_key, range_key = self.get_keys_value(table, keys) return table.get_item(hash_key, range_key) diff --git a/moto/dynamodb2/responses.py b/moto/dynamodb2/responses.py index 5713910d9..81b6a7f47 100644 --- a/moto/dynamodb2/responses.py +++ b/moto/dynamodb2/responses.py @@ -196,8 +196,8 @@ class DynamoHandler(BaseResponse): return dynamo_json_dump(item_dict) else: # Item not found - er = 'com.amazonaws.dynamodb.v20111205#ResourceNotFoundException' - return self.error(er, status=404) + er = '{}' + return self.error(er, status=200) def batch_get_item(self): table_batches = self.body['RequestItems'] diff --git a/tests/test_dynamodb2/test_dynamodb_table_without_range_key.py b/tests/test_dynamodb2/test_dynamodb_table_without_range_key.py index 0f845759e..1710bd650 100644 --- a/tests/test_dynamodb2/test_dynamodb_table_without_range_key.py +++ b/tests/test_dynamodb2/test_dynamodb_table_without_range_key.py @@ -10,7 +10,7 @@ try: from boto.dynamodb2.fields import HashKey from boto.dynamodb2.table import Table from boto.dynamodb2.table import Item - from boto.dynamodb2.exceptions import ConditionalCheckFailedException + from boto.dynamodb2.exceptions import ConditionalCheckFailedException, ItemNotFound except ImportError: pass @@ -369,6 +369,13 @@ def test_get_key_fields(): kf[0].should.equal('forum_name') +@requires_boto_gte("2.9") +@mock_dynamodb2 +def test_get_missing_item(): + table = create_table() + table.get_item.when.called_with(forum_name='missing').should.throw(ItemNotFound) + + @requires_boto_gte("2.9") @mock_dynamodb2 def test_get_special_item():