def test_one_page(self): self.connection.expect._call_.withArguments( self.ActionChecker("BatchGetItem", {"RequestItems": {"Aaa": {"Keys": [{"h": {"S": "a"}}, {"h": {"S": "b"}}]}}}) ).andReturn( _lv.BatchGetItemResponse(Responses={"Aaa": [{"h": {"S": "c"}}, {"h": {"S": "d"}}]}) ) self.assertEqual( list(_lv.iterate_batch_get_item(self.connection.object, "Aaa", {"h": "a"}, {"h": "b"})), [{"h": "c"}, {"h": "d"}] )
def test_one_page(self): self.connection.expect._call_.withArguments( self.ActionChecker("BatchGetItem", {"RequestItems": {"Aaa": {"Keys": [{"h": {"S": "a"}}, {"h": {"S": "b"}}]}}}) ).andReturn( _lv.BatchGetItemResponse(Responses={"Aaa": [{"h": {"S": "c"}}, {"h": {"S": "d"}}]}) ) self.assertEqual( list(_lv.iterate_batch_get_item(self.connection.object, "Aaa", {"h": u"a"}, {"h": u"b"})), [{"h": "c"}, {"h": "d"}] )
def test_several_pages(self): self.connection.expect._call_.withArguments( self.ActionChecker("BatchGetItem", {"RequestItems": {"Aaa": {"Keys": [{"h": {"N": str(i)}} for i in range(0, 100)]}}}) ).andReturn( _lv.BatchGetItemResponse(Responses={"Aaa": [{"h": {"N": str(i)}} for i in range(1000, 1100)]}) ) self.connection.expect._call_.withArguments( self.ActionChecker("BatchGetItem", {"RequestItems": {"Aaa": {"Keys": [{"h": {"N": str(i)}} for i in range(100, 200)]}}}) ).andReturn( _lv.BatchGetItemResponse(Responses={"Aaa": [{"h": {"N": str(i)}} for i in range(1100, 1200)]}) ) self.connection.expect._call_.withArguments( self.ActionChecker("BatchGetItem", {"RequestItems": {"Aaa": {"Keys": [{"h": {"N": str(i)}} for i in range(200, 250)]}}}) ).andReturn( _lv.BatchGetItemResponse(Responses={"Aaa": [{"h": {"N": str(i)}} for i in range(1200, 1250)]}) ) self.assertEqual( list(_lv.iterate_batch_get_item(self.connection.object, "Aaa", ({"h": i} for i in range(0, 250)))), [{"h": i} for i in range(1000, 1250)] )
def test_several_pages(self): self.connection.expect._call_.withArguments( self.ActionChecker("BatchGetItem", {"RequestItems": {"Aaa": {"Keys": [{"h": {"N": str(i)}} for i in range(0, 100)]}}}) ).andReturn( _lv.BatchGetItemResponse(Responses={"Aaa": [{"h": {"N": str(i)}} for i in range(1000, 1100)]}) ) self.connection.expect._call_.withArguments( self.ActionChecker("BatchGetItem", {"RequestItems": {"Aaa": {"Keys": [{"h": {"N": str(i)}} for i in range(100, 200)]}}}) ).andReturn( _lv.BatchGetItemResponse(Responses={"Aaa": [{"h": {"N": str(i)}} for i in range(1100, 1200)]}) ) self.connection.expect._call_.withArguments( self.ActionChecker("BatchGetItem", {"RequestItems": {"Aaa": {"Keys": [{"h": {"N": str(i)}} for i in range(200, 250)]}}}) ).andReturn( _lv.BatchGetItemResponse(Responses={"Aaa": [{"h": {"N": str(i)}} for i in range(1200, 1250)]}) ) self.assertEqual( list(_lv.iterate_batch_get_item(self.connection.object, "Aaa", ({"h": i} for i in range(0, 250)))), [{"h": i} for i in range(1000, 1250)] )
def test(self): keys = [item["h"] for item in _lv.iterate_batch_get_item(self.connection, "Aaa", ({"h": self.key(i)} for i in range(250)))] self.assertEqual(sorted(keys), [self.key(i) for i in range(250)])
def test_no_keys(self): self.assertEqual( list(_lv.iterate_batch_get_item(self.connection.object, "Aaa", [])), [] )
def test(self): keys = [item["h"] for item in _lv.iterate_batch_get_item(self.connection, "Aaa", ({"h": self.key(i)} for i in range(250)))] self.assertEqual(sorted(keys), [self.key(i) for i in range(250)])
def test_no_keys(self): self.assertEqual( list(_lv.iterate_batch_get_item(self.connection.object, "Aaa", [])), [] )