def test_one_unprocessed_key(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"}}]}, UnprocessedKeys={"Aaa": {"Keys": [{"h": {"S": "d"}}]}}) ) self.connection.expect._call_.withArguments( self.ActionChecker("BatchGetItem", {"RequestItems": {"Aaa": {"Keys": [{"h": {"S": "d"}}]}}}) ).andReturn( _lv.BatchGetItemResponse(Responses={"Aaa": [{"h": {"S": "e"}}]}) ) self.assertEqual( list(_lv.iterate_batch_get_item(self.connection.object, "Aaa", {"h": "a"}, {"h": "b"})), [{"h": "c"}, {"h": "e"}] )
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)] )