From cdc007fc63240d093afaf6e2e79542126928c31f Mon Sep 17 00:00:00 2001 From: Ian Auld Date: Fri, 21 Apr 2017 14:55:25 -0700 Subject: [PATCH] Added test for query using an attribute that is not a range/hash key --- .../test_dynamodb_table_with_range_key.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/test_dynamodb2/test_dynamodb_table_with_range_key.py b/tests/test_dynamodb2/test_dynamodb_table_with_range_key.py index 58e0d66d1..c740350ef 100644 --- a/tests/test_dynamodb2/test_dynamodb_table_with_range_key.py +++ b/tests/test_dynamodb2/test_dynamodb_table_with_range_key.py @@ -838,6 +838,47 @@ def test_query_filter_gte(): list(results).should.have.length_of(2) +@requires_boto_gte("2.9") +@mock_dynamodb2_deprecated +def test_query_non_hash_range_key(): + table = create_table_with_local_indexes() + item_data = [ + { + 'forum_name': 'Cool Forum', + 'subject': 'Check this out!', + 'version': '1', + 'threads': 1, + }, + { + 'forum_name': 'Cool Forum', + 'subject': 'Read this now!', + 'version': '3', + 'threads': 5, + }, + { + 'forum_name': 'Cool Forum', + 'subject': 'Please read this... please', + 'version': '2', + 'threads': 0, + } + ] + for data in item_data: + item = Item(table, data) + item.save(overwrite=True) + + results = table.query( + forum_name__eq='Cool Forum', version__gt="2" + ) + results = list(results) + results.should.have.length_of(1) + + results = table.query( + forum_name__eq='Cool Forum', version__lt="3" + ) + results = list(results) + results.should.have.length_of(2) + + @mock_dynamodb2_deprecated def test_reverse_query(): conn = boto.dynamodb2.layer1.DynamoDBConnection()