fix scan return CapacityUnits
This commit is contained in:
parent
ba187e94b8
commit
51c3fec6dd
@ -427,7 +427,10 @@ class DynamoHandler(BaseResponse):
|
|||||||
result = {
|
result = {
|
||||||
"Count": len(items),
|
"Count": len(items),
|
||||||
"Items": [item.attrs for item in items],
|
"Items": [item.attrs for item in items],
|
||||||
"ConsumedCapacityUnits": 1,
|
'ConsumedCapacity': {
|
||||||
|
'TableName': name,
|
||||||
|
'CapacityUnits': 1,
|
||||||
|
},
|
||||||
"ScannedCount": scanned_count
|
"ScannedCount": scanned_count
|
||||||
}
|
}
|
||||||
if last_evaluated_key is not None:
|
if last_evaluated_key is not None:
|
||||||
|
@ -194,3 +194,37 @@ def test_query_invalid_table():
|
|||||||
conn.query(TableName='invalid_table', KeyConditionExpression='index1 = :partitionkeyval', ExpressionAttributeValues={':partitionkeyval': {'S':'test'}})
|
conn.query(TableName='invalid_table', KeyConditionExpression='index1 = :partitionkeyval', ExpressionAttributeValues={':partitionkeyval': {'S':'test'}})
|
||||||
except ClientError as exception:
|
except ClientError as exception:
|
||||||
assert exception.response['Error']['Code'] == "ResourceNotFoundException"
|
assert exception.response['Error']['Code'] == "ResourceNotFoundException"
|
||||||
|
|
||||||
|
|
||||||
|
@requires_boto_gte("2.9")
|
||||||
|
@mock_dynamodb2
|
||||||
|
def test_scan_returns_consumed_capacity():
|
||||||
|
name = 'TestTable'
|
||||||
|
conn = boto3.client('dynamodb',
|
||||||
|
region_name='us-west-2',
|
||||||
|
aws_access_key_id="ak",
|
||||||
|
aws_secret_access_key="sk")
|
||||||
|
|
||||||
|
conn.create_table(TableName=name,
|
||||||
|
KeySchema=[{'AttributeName':'forum_name','KeyType':'HASH'}],
|
||||||
|
AttributeDefinitions=[{'AttributeName':'forum_name','AttributeType':'S'}],
|
||||||
|
ProvisionedThroughput={'ReadCapacityUnits':5,'WriteCapacityUnits':5})
|
||||||
|
|
||||||
|
conn.put_item(
|
||||||
|
TableName=name,
|
||||||
|
Item={
|
||||||
|
'forum_name': { 'S': 'LOLCat Forum' },
|
||||||
|
'subject': { 'S': 'Check this out!' },
|
||||||
|
'Body': { 'S': 'http://url_to_lolcat.gif'},
|
||||||
|
'SentBy': { 'S': "test" },
|
||||||
|
'ReceivedTime': { 'S': '12/9/2011 11:36:03 PM'},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
response = conn.scan(
|
||||||
|
TableName=name,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert 'ConsumedCapacity' in response
|
||||||
|
assert 'CapacityUnits' in response['ConsumedCapacity']
|
||||||
|
assert response['ConsumedCapacity']['TableName'] == name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user