def test_async(self): # test async calls cadc = Cadc() # run the query in sync mode first expected = cadc.exec_sync( "select top 3 observationID from caom2.Observation where " "collection='IRIS' order by observationID") # now run the query in async mode job = cadc.create_async( "select top 3 observationID from caom2.Observation where " "collection='IRIS' order by observationID") job = job.run().wait() job.raise_if_error() result = job.fetch_result().to_table() assert len(expected) == len(result) for ii in range(0, 2): assert expected['observationID'][ii] == result['observationID'][ii] # load job again loaded_job = cadc.load_async_job(job.job_id) result = loaded_job.fetch_result().to_table() assert len(expected) == len(result) for ii in range(0, 2): assert expected['observationID'][ii] == result['observationID'][ii]
def test_list_jobs(self): cadc = Cadc() cadc.login(certificate_file=os.environ['CADC_CERT']) job = cadc.create_async( "select top 3 observationID from caom2.Observation where " "collection='IRIS' order by observationID") job = job.run().wait() job.raise_if_error() job.fetch_result().to_table() jobs = cadc.list_async_jobs() assert len(jobs) > 0 if len(jobs) > 5: jobs_subset = cadc.list_async_jobs(last=5) assert len(jobs_subset) == 5