def test_bulk_search_task_download_async(bulk_search_task: BulkSearchTask):
    task_uuid = bulk_search_task.uuid
    bs_download_url = f'https://datalake.cert.orangecyberdefense.com/api/v2/mrti/bulk-search/task/{task_uuid}/'
    expected_result = "bulk search download"
    responses.add(responses.GET, bs_download_url, json=expected_result, status=200)

    loop = asyncio.get_event_loop()
    download_result = loop.run_until_complete(bulk_search_task.download_async())

    assert download_result == expected_result
async def test_bulk_search_task_download_async_timeout(bulk_search_task: BulkSearchTask):
    with responses.RequestsMock() as response_context:  # pytest.mark.asyncio is not compatible with responses decorator
        bulk_search_task.state = BulkSearchTaskState.IN_PROGRESS  # download will never be ready
        bs_update_json = copy.deepcopy(bs_status_json)
        bs_update_json['results'][0]['state'] = 'IN_PROGRESS'
        bs_status_url = f'https://datalake.cert.orangecyberdefense.com/api/v2/mrti/bulk-search/tasks/'
        response_context.add(responses.POST, bs_status_url, json=bs_update_json, status=200)

        loop = asyncio.get_event_loop()
        task = loop.create_task(bulk_search_task.download_async(timeout=0.2))
        with pytest.raises(TimeoutError):
            await task