parent
b8ba7980a0
commit
9bf8fd3417
6 changed files with 282 additions and 10 deletions
|
|
@ -1531,6 +1531,7 @@ def test_dynamodb_streams_2():
|
|||
}
|
||||
assert 'LatestStreamLabel' in resp['TableDescription']
|
||||
assert 'LatestStreamArn' in resp['TableDescription']
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_condition_expressions():
|
||||
|
|
@ -1696,8 +1697,8 @@ def test_query_gsi_with_range_key():
|
|||
res = dynamodb.query(TableName='test', IndexName='test_gsi',
|
||||
KeyConditionExpression='gsi_hash_key = :gsi_hash_key AND gsi_range_key = :gsi_range_key',
|
||||
ExpressionAttributeValues={
|
||||
':gsi_hash_key': {'S': 'key1'},
|
||||
':gsi_range_key': {'S': 'range1'}
|
||||
':gsi_hash_key': {'S': 'key1'},
|
||||
':gsi_range_key': {'S': 'range1'}
|
||||
})
|
||||
res.should.have.key("Count").equal(1)
|
||||
res.should.have.key("Items")
|
||||
|
|
@ -1706,3 +1707,45 @@ def test_query_gsi_with_range_key():
|
|||
'gsi_hash_key': {'S': 'key1'},
|
||||
'gsi_range_key': {'S': 'range1'},
|
||||
})
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_scan_by_non_exists_index():
|
||||
dynamodb = boto3.client('dynamodb', region_name='us-east-1')
|
||||
|
||||
dynamodb.create_table(
|
||||
TableName='test',
|
||||
KeySchema=[{'AttributeName': 'id', 'KeyType': 'HASH'}],
|
||||
AttributeDefinitions=[
|
||||
{'AttributeName': 'id', 'AttributeType': 'S'},
|
||||
{'AttributeName': 'gsi_col', 'AttributeType': 'S'}
|
||||
],
|
||||
ProvisionedThroughput={'ReadCapacityUnits': 1, 'WriteCapacityUnits': 1},
|
||||
GlobalSecondaryIndexes=[
|
||||
{
|
||||
'IndexName': 'test_gsi',
|
||||
'KeySchema': [
|
||||
{
|
||||
'AttributeName': 'gsi_col',
|
||||
'KeyType': 'HASH'
|
||||
},
|
||||
],
|
||||
'Projection': {
|
||||
'ProjectionType': 'ALL',
|
||||
},
|
||||
'ProvisionedThroughput': {
|
||||
'ReadCapacityUnits': 1,
|
||||
'WriteCapacityUnits': 1
|
||||
}
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
with assert_raises(ClientError) as ex:
|
||||
dynamodb.scan(TableName='test', IndexName='non_exists_index')
|
||||
|
||||
ex.exception.response['Error']['Code'].should.equal('ValidationException')
|
||||
ex.exception.response['ResponseMetadata']['HTTPStatusCode'].should.equal(400)
|
||||
ex.exception.response['Error']['Message'].should.equal(
|
||||
'The table does not have the specified index: non_exists_index'
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue