def test_raw_query(self): bulk = SalesforceBulkipy(self.sessionId, self.endpoint) self.bulk = bulk job_id = bulk.create_query_job("Contact") self.jobs.append(job_id) self.assertIsNotNone(re.match("\w+", job_id)) batch_id = bulk.query(job_id, "Select Id,Name,Email from Contact Limit 1000") self.assertIsNotNone(re.match("\w+", batch_id)) while not bulk.is_batch_done(job_id, batch_id): print("Job not done yet...") print(bulk.batch_status(job_id, batch_id)) time.sleep(2) self.results = "" def save_results(tfile, **kwargs): print("in save results") self.results = tfile.read() flag = bulk.get_batch_results(job_id, batch_id, callback=save_results) self.assertTrue(flag) self.assertTrue(len(self.results) > 0) self.assertIn('"', self.results)
def test_raw_query(self): bulk = SalesforceBulkipy(self.sessionId, self.endpoint) self.bulk = bulk job_id = bulk.create_query_job("Contact") self.jobs.append(job_id) self.assertIsNotNone(re.match("\w+", job_id)) # test the job state method self.assertEqual(bulk.job_state(job_id=job_id), 'Open') batch_id = bulk.query(job_id, "Select Id,Name,Email from Contact Limit 1000") self.assertIsNotNone(re.match("\w+", batch_id)) while not bulk.is_batch_done(job_id, batch_id): print("Job not done yet...") print(bulk.batch_status(job_id, batch_id)) time.sleep(2) results = bulk.get_all_results_for_batch(batch_id=batch_id, job_id=job_id) results = list(list(x) for x in results) self.assertTrue(len(results) > 0) self.assertTrue(len(results[0]) > 0) self.assertIn('"', results[0][0]) results = bulk.get_batch_result_iter(batch_id=batch_id, job_id=job_id) results = list(results) self.assertTrue(len(results) > 0) self.assertTrue(len(results[0]) > 0) self.assertIn('"', results[0][0])