Esempio n. 1
0
 def test_local_index(self):
     """Can query on a local index"""
     hash_key = DynamoKey("id", data_type=STRING)
     range_key = DynamoKey("num", data_type=NUMBER)
     index_field = DynamoKey("name")
     index = LocalIndex.keys("name-index", index_field)
     self.dynamo.create_table("foobar",
                              hash_key,
                              range_key,
                              indexes=[index])
     item = {
         "id": "a",
         "num": 1,
         "name": "baz",
     }
     self.dynamo.put_item("foobar", item)
     ret = self.dynamo.query(
         "foobar",
         "id = :id and #name = :name",
         alias={"#name": "name"},
         index="name-index",
         id="a",
         name="baz",
     )
     self.assertCountEqual(list(ret), [item])
Esempio n. 2
0
 def test_create_local_keys_index(self):
     """Create a table with a local KeysOnly index"""
     hash_key = DynamoKey("id", data_type=STRING)
     range_key = DynamoKey("num", data_type=NUMBER)
     index_field = DynamoKey("name")
     index = LocalIndex.keys("name-index", index_field)
     table = Table("foobar", hash_key, range_key, [index])
     self.dynamo.create_table("foobar", hash_key, range_key, indexes=[index])
     desc = self.dynamo.describe_table("foobar")
     self.assertEqual(desc, table)
Esempio n. 3
0
 def test_create_local_keys_index(self):
     """ Create a table with a local KeysOnly index """
     hash_key = DynamoKey('id', data_type=STRING)
     range_key = DynamoKey('num', data_type=NUMBER)
     index_field = DynamoKey('name')
     index = LocalIndex.keys('name-index', index_field)
     table = Table('foobar', hash_key, range_key, [index])
     self.dynamo.create_table(
         'foobar', hash_key, range_key, indexes=[index])
     desc = self.dynamo.describe_table('foobar')
     self.assertEqual(desc, table)
Esempio n. 4
0
 def test_local_index(self):
     """ Can query on a local index """
     hash_key = DynamoKey('id', data_type=STRING)
     range_key = DynamoKey('num', data_type=NUMBER)
     index_field = DynamoKey('name')
     index = LocalIndex.keys('name-index', index_field)
     self.dynamo.create_table('foobar', hash_key, range_key,
                              indexes=[index])
     item = {
         'id': 'a',
         'num': 1,
         'name': 'baz',
     }
     self.dynamo.put_item('foobar', item)
     ret = self.dynamo.query('foobar', id__eq='a', name__eq='baz',
                             index='name-index')
     self.assertItemsEqual(list(ret), [item])
Esempio n. 5
0
 def test_local_index(self):
     """ Can query on a local index """
     hash_key = DynamoKey('id', data_type=STRING)
     range_key = DynamoKey('num', data_type=NUMBER)
     index_field = DynamoKey('name')
     index = LocalIndex.keys('name-index', index_field)
     self.dynamo.create_table('foobar', hash_key, range_key,
                              indexes=[index])
     item = {
         'id': 'a',
         'num': 1,
         'name': 'baz',
     }
     self.dynamo.put_item('foobar', item)
     ret = self.dynamo.query('foobar', id__eq='a', name__eq='baz',
                             index='name-index')
     self.assertItemsEqual(list(ret), [item])