userver: samples/testsuite-support/tests/test_tasks.py
Loading...
Searching...
No Matches
samples/testsuite-support/tests/test_tasks.py
1import pytest
2
3
4async def test_unknown_tasks(service_client):
5 with pytest.raises(service_client.TestsuiteTaskNotFound):
6 await service_client.run_task('unknown-task')
7
8
9async def test_task_run(service_client, testpoint):
10 @testpoint('sample-task/action')
11 def task_action(data):
12 pass
13
14 # /// [run_task]
15 await service_client.run_task('sample-task')
16 assert task_action.times_called == 1
17 # /// [run_task]
18
19
20async def test_task_spawn(service_client, testpoint):
21 @testpoint('sample-task/action')
22 def task_action(data):
23 pass
24
25 # /// [spawn_task]
26 async with service_client.spawn_task('sample-task'):
27 await task_action.wait_call()
28 # /// [spawn_task]
29
30
31async def test_list_tasks(service_client):
32 tasks = await service_client.list_tasks()
33 assert 'sample-task' in tasks