def test_batch_results_to_list(self): batch_mgr = batch.BatchManager("create") json_data = { "BatchItemResponse": [{ "Customer": { "Id": 164 }, "bId": "2" }, { "Fault": { "type": "ValidationFault", "Error": [{ "Message": "Duplicate Name Exists Error", "code": "6240", "Detail": "detail message", "element": "" }] }, "bId": "1" }], "time": "2015-08-10T11:44:02.957-07:00" } batch_request = batch_mgr.list_to_batch_request(self.obj_list) batch_request.BatchItemRequest[0].bId = "1" batch_request.BatchItemRequest[1].bId = "2" results = batch_mgr.batch_results_to_list(json_data, batch_request, self.obj_list) self.assertEqual(len(results.faults), 1) self.assertEqual(len(results.successes), 1)
def test_list_to_batch_request(self): batch_mgr = batch.BatchManager("create") obj_list = [self.object1, self.object2] batch_request = batch_mgr.list_to_batch_request(obj_list) self.assertEqual(len(batch_request.BatchItemRequest), 2) batch_item = batch_request.BatchItemRequest[0] self.assertTrue(batch_item.bId) self.assertTrue(len(batch_item.bId) < 50) self.assertEqual(batch_item.operation, "create") self.assertEqual(batch_item.get_object(), self.object1)