Пример #1
0
 def do_batch(self, elements):
   """
   Execute a batch request with one or more elements. If any element fails,
   the entire request is rolled back and subsequent elements are ignored.
   @param elements: A list of ApiBatchRequestElements
   @return: 2-tuple (overall success, list of ApiBatchResponseElements).
   """
   return batch.do_batch(self, elements)
Пример #2
0
 def do_batch(self, elements):
     """
 Execute a batch request with one or more elements. If any element fails,
 the entire request is rolled back and subsequent elements are ignored.
 @param elements: A list of ApiBatchRequestElements
 @return: 2-tuple (overall success, list of ApiBatchResponseElements).
 """
     return batch.do_batch(self, elements)
Пример #3
0
 def test_execute_batch(self):
   resource = utils.MockResource(self)
   elems = []
   elems.append(ApiBatchRequestElement(resource,
                                       method='GET',
                                       url='/1/2/3'))
   elems.append(ApiBatchRequestElement(resource,
                                       method='POST',
                                       url='/4/5/6/7',
                                       body='asdf'))
   resource.expect("POST", "/batch",
                   data=elems,
                   retdata={ 'success' : False, 'items' : [] })
   ret = batch.do_batch(resource, elems)
   self.assertIsInstance(ret, ApiBatchResponseList)
   self.assertIsInstance(ret.success, bool)
   self.assertFalse(ret.success)
   self.assertEquals(0, len(ret))
Пример #4
0
 def test_execute_batch(self):
     resource = utils.MockResource(self)
     elems = []
     elems.append(
         ApiBatchRequestElement(resource, method='GET', url='/1/2/3'))
     elems.append(
         ApiBatchRequestElement(resource,
                                method='POST',
                                url='/4/5/6/7',
                                body='asdf'))
     resource.expect("POST",
                     "/batch",
                     data=elems,
                     retdata={
                         'success': False,
                         'items': []
                     })
     ret = batch.do_batch(resource, elems)
     self.assertIsInstance(ret, ApiBatchResponseList)
     self.assertIsInstance(ret.success, bool)
     self.assertFalse(ret.success)
     self.assertEquals(0, len(ret))