|
5 | 5 | # pylint: disable=unused-argument |
6 | 6 | # pylint: disable=unused-variable |
7 | 7 |
|
| 8 | +import asyncio |
8 | 9 | import datetime |
9 | 10 | from collections.abc import Awaitable, Callable |
10 | 11 |
|
@@ -70,9 +71,42 @@ async def test_get( |
70 | 71 |
|
71 | 72 | async def test_list( |
72 | 73 | aiopg_engine, |
| 74 | + publish_project: Callable[[], Awaitable[PublishedProject]], |
| 75 | + run_metadata: RunMetadataDict, |
| 76 | + faker: Faker, |
73 | 77 | ): |
74 | 78 | assert await CompRunsRepository(aiopg_engine).list() == [] |
75 | 79 |
|
| 80 | + published_project = await publish_project() |
| 81 | + assert await CompRunsRepository(aiopg_engine).list() == [] |
| 82 | + |
| 83 | + created = await CompRunsRepository(aiopg_engine).create( |
| 84 | + user_id=published_project.user["id"], |
| 85 | + project_id=published_project.project.uuid, |
| 86 | + cluster_id=DEFAULT_CLUSTER_ID, |
| 87 | + iteration=None, |
| 88 | + metadata=run_metadata, |
| 89 | + use_on_demand_clusters=faker.pybool(), |
| 90 | + ) |
| 91 | + assert await CompRunsRepository(aiopg_engine).list() == [created] |
| 92 | + |
| 93 | + created = [created] + await asyncio.gather( |
| 94 | + *( |
| 95 | + CompRunsRepository(aiopg_engine).create( |
| 96 | + user_id=published_project.user["id"], |
| 97 | + project_id=published_project.project.uuid, |
| 98 | + cluster_id=DEFAULT_CLUSTER_ID, |
| 99 | + iteration=created.iteration + n + 1, |
| 100 | + metadata=run_metadata, |
| 101 | + use_on_demand_clusters=faker.pybool(), |
| 102 | + ) |
| 103 | + for n in range(50) |
| 104 | + ) |
| 105 | + ) |
| 106 | + assert sorted( |
| 107 | + await CompRunsRepository(aiopg_engine).list(), key=lambda x: x.iteration |
| 108 | + ) == sorted(created, key=lambda x: x.iteration) |
| 109 | + |
76 | 110 |
|
77 | 111 | async def test_create( |
78 | 112 | aiopg_engine, |
|
0 commit comments