Skip to content

Commit

Permalink
Test query by non exists index
Browse files Browse the repository at this point in the history
  • Loading branch information
shmygol committed Dec 11, 2019
1 parent 1d0de93 commit be5986c
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/test_dynamodb2/test_dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2630,6 +2630,43 @@ def test_scan_by_non_exists_index():
)


@mock_dynamodb2
def test_query_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(ValueError) as ex:
dynamodb.query(
TableName="test",
IndexName="non_exists_index",
KeyConditionExpression="CarModel=M",
)

str(ex.exception).should.equal(
"Invalid index: non_exists_index for table: test. Available indexes are: test_gsi"
)


@mock_dynamodb2
def test_batch_items_returns_all():
dynamodb = _create_user_table()
Expand Down

0 comments on commit be5986c

Please sign in to comment.