

@unittest.skipUnless(RUN_INDEXES, 'RUN_INDEXES is 0')
def test_secondary_index_query(self):
    if (not self.is_2i_supported()):
        raise unittest.SkipTest('2I not supported')
    (bucket, o1, o2, o3, o4) = self._create_index_objects()
    results = bucket.get_index('field1_bin', 'val2')
    self.assertEqual(1, len(results))
    self.assertEqual(o2.key, str(results[0]))
    results = bucket.get_index('field1_bin', 'val2', 'val4')
    vals = set([str(key) for key in results])
    self.assertEqual(3, len(results))
    self.assertEqual(set([o2.key, o3.key, o4.key]), vals)
    results = bucket.get_index('field2_int', 1002)
    self.assertEqual(1, len(results))
    self.assertEqual(o2.key, str(results[0]))
    results = bucket.get_index('field2_int', 1002, 1004)
    vals = set([str(key) for key in results])
    self.assertEqual(3, len(results))
    self.assertEqual(set([o2.key, o3.key, o4.key]), vals)

dataset/ETHPy150Open basho/riak-python-client/riak/tests/test_2i.py TwoITests.test_secondary_index_query/original