async def test_list_results_with_pagination(test_client): search = Search(test_client) search_job = SearchJob(query=STANDARD_QUERY) job = search.create_job(search_job=search_job) assert (job.query == STANDARD_QUERY) assert (job.sid is not None) assert (job.status is not None) job2 = await wait_for_job(search.get_job, job.sid) assert (isinstance(job, SearchJob)) assert (job2.status == 'done') assert (job2.results_available == 5) results = search.list_results(job2.sid, offset=0, count=3) assert (isinstance(results, ListSearchResultsResponse)) assert (len(results.results) == 3) results = search.list_results(job2.sid, offset=3, count=5) assert (isinstance(results, ListSearchResultsResponse)) assert (len(results.results) == 2) results = search.list_results(job2.sid, offset=10, count=10) assert (isinstance(results, ListSearchResultsResponse)) assert (len(results.results) == 0)
def test_create_job(test_client): search = Search(test_client) search_job = SearchJob(query=STANDARD_QUERY) job = search.create_job(search_job=search_job) assert (isinstance(job, SearchJob)) assert (job.query == STANDARD_QUERY) assert (job.sid is not None) assert (job.status is not None)
def test_list_jobs(test_client): search = Search(test_client) jobs = search.list_jobs() assert (len(jobs) > 0) assert (isinstance(jobs, list)) for job in jobs: assert (isinstance(job, SearchJob))
def test_list_jobs_with_args(test_client): search = Search(test_client) jobs = search.list_jobs() assert (len(jobs) > 0) for job in jobs: assert (isinstance(job, SearchJob)) assert (job.status is not None) assert (job.results_available is not None) assert (job.sid is not None) assert (job.query is not None) assert (job.module is not None) assert (job.percent_complete is not None)
async def test_wait_for_job(test_client): search = Search(test_client) search_job = SearchJob(query=STANDARD_QUERY) job = search.create_job(search_job=search_job) job2 = await wait_for_job(search.get_job, job.sid) assert (isinstance(job2, SearchJob)) assert (job2.status == 'done') assert (job2.results_available == 5) assert (job2.sid is not None) assert (job2.query is not None) assert (job2.module is not None) assert (job2.percent_complete is not None)
def test_update_job(test_client): search = Search(test_client) # create job search_job = SearchJob(query=STANDARD_QUERY) job = search.create_job(search_job=search_job) assert (isinstance(job, SearchJob)) # get job _job = search.get_job(job.sid) if _job.status == 'running': # update canceled_job = UpdateJob(status='canceled') updated_job = search.update_job(job.sid, update_job=canceled_job) assert (isinstance(updated_job, SearchJob))
async def test_list_results(test_client): search = Search(test_client) search_job = SearchJob(query=STANDARD_QUERY) job = search.create_job(search_job=search_job) assert (job.query == STANDARD_QUERY) assert (job.sid is not None) assert (job.status is not None) results = search.list_results(job.sid) assert (isinstance(results, ListSearchResultsResponse)) assert (results.next_link is not None) job2 = await wait_for_job(search.get_job, job.sid) assert (isinstance(job, SearchJob)) assert (job2.status == 'done') results2 = search.list_results(job2.sid) assert (isinstance(results2, ListSearchResultsResponse))