Skip to content

Commit 3dd3b33

Browse files
authored
Consistently use mut marker for tests that write to the database (#290)
Even within a transaction, as some requests may stall until transactions with write requests are committed/aborted.
1 parent 3e961e9 commit 3dd3b33

File tree

7 files changed

+15
-1
lines changed

7 files changed

+15
-1
lines changed

tests/routers/openml/dataset_tag_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ async def test_dataset_tag_rejects_unauthorized(key: ApiKey, py_api: httpx.Async
2828
assert error["code"] == "103"
2929

3030

31+
@pytest.mark.mut
3132
@pytest.mark.parametrize(
3233
"key",
3334
[ApiKey.ADMIN, ApiKey.SOME_USER, ApiKey.OWNER_USER],
@@ -48,6 +49,7 @@ async def test_dataset_tag(
4849
assert tag in tags
4950

5051

52+
@pytest.mark.mut
5153
async def test_dataset_tag_returns_existing_tags(py_api: httpx.AsyncClient) -> None:
5254
dataset_id, tag = 1, "test"
5355
response = await py_api.post(
@@ -58,6 +60,7 @@ async def test_dataset_tag_returns_existing_tags(py_api: httpx.AsyncClient) -> N
5860
assert response.json() == {"data_tag": {"id": str(dataset_id), "tag": ["study_14", tag]}}
5961

6062

63+
@pytest.mark.mut
6164
async def test_dataset_tag_fails_if_tag_exists(py_api: httpx.AsyncClient) -> None:
6265
dataset_id, tag = 1, "study_14" # Dataset 1 already is tagged with 'study_14'
6366
response = await py_api.post(

tests/routers/openml/datasets_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ async def test_dataset_status_unauthorized(
316316
assert response.status_code == HTTPStatus.FORBIDDEN
317317

318318

319+
@pytest.mark.mut
319320
async def test_dataset_no_500_with_multiple_processing_entries(
320321
py_api: httpx.AsyncClient,
321322
expdb_test: AsyncConnection,

tests/routers/openml/migration/datasets_migration_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ async def test_private_dataset_owner_access(
156156
assert new_response.json()["id"] == private_dataset
157157

158158

159+
@pytest.mark.mut
159160
@pytest.mark.parametrize(
160161
"dataset_id",
161162
[*range(1, 10), 101, 131],

tests/routers/openml/migration/flows_migration_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from tests.conftest import Flow
1515

1616

17-
@pytest.mark.mut
1817
async def test_flow_exists_not(
1918
py_api: httpx.AsyncClient,
2019
php_api: httpx.AsyncClient,

tests/routers/openml/migration/setups_migration_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ async def _temporary_tags(
4747
return _temporary_tags
4848

4949

50+
@pytest.mark.mut
5051
@pytest.mark.parametrize(
5152
"api_key",
5253
[ApiKey.ADMIN, ApiKey.SOME_USER, ApiKey.OWNER_USER],
@@ -165,6 +166,7 @@ async def test_setup_untag_response_is_identical_tag_doesnt_exist(
165166
)
166167

167168

169+
@pytest.mark.mut
168170
@pytest.mark.parametrize(
169171
"api_key",
170172
[ApiKey.ADMIN, ApiKey.SOME_USER],
@@ -247,6 +249,7 @@ async def test_setup_tag_response_is_identical_setup_doesnt_exist(
247249
)
248250

249251

252+
@pytest.mark.mut
250253
async def test_setup_tag_response_is_identical_tag_already_exists(
251254
py_api: httpx.AsyncClient,
252255
php_api: httpx.AsyncClient,

tests/routers/openml/qualities_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ async def test_list_qualities_identical(
4242
# To keep the test idempotent, we cannot test if reaction to database changes is identical
4343

4444

45+
@pytest.mark.mut
4546
async def test_list_qualities(py_api: httpx.AsyncClient, expdb_test: AsyncConnection) -> None:
4647
response = await py_api.get("/datasets/qualities/list")
4748
assert response.status_code == HTTPStatus.OK

tests/routers/openml/study_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from http import HTTPStatus
33

44
import httpx
5+
import pytest
56
from sqlalchemy import text
67
from sqlalchemy.ext.asyncio import AsyncConnection
78

@@ -458,6 +459,7 @@ async def test_get_task_study_by_alias(py_api: httpx.AsyncClient) -> None:
458459
assert response.json() == expected
459460

460461

462+
@pytest.mark.mut
461463
async def test_create_task_study(py_api: httpx.AsyncClient) -> None:
462464
response = await py_api.post(
463465
f"/studies?api_key={ApiKey.SOME_USER}",
@@ -516,6 +518,7 @@ async def _attach_tasks_to_study(
516518
)
517519

518520

521+
@pytest.mark.mut
519522
async def test_attach_task_to_study(py_api: httpx.AsyncClient, expdb_test: AsyncConnection) -> None:
520523
response = await _attach_tasks_to_study(
521524
study_id=1,
@@ -528,6 +531,7 @@ async def test_attach_task_to_study(py_api: httpx.AsyncClient, expdb_test: Async
528531
assert response.json() == {"study_id": 1, "main_entity_type": StudyType.TASK}
529532

530533

534+
@pytest.mark.mut
531535
async def test_attach_task_to_study_needs_owner(
532536
py_api: httpx.AsyncClient, expdb_test: AsyncConnection
533537
) -> None:
@@ -542,6 +546,7 @@ async def test_attach_task_to_study_needs_owner(
542546
assert response.status_code == HTTPStatus.FORBIDDEN, response.content
543547

544548

549+
@pytest.mark.mut
545550
async def test_attach_task_to_study_already_linked_raises(
546551
py_api: httpx.AsyncClient,
547552
expdb_test: AsyncConnection,
@@ -561,6 +566,7 @@ async def test_attach_task_to_study_already_linked_raises(
561566
assert error["detail"] == "Task 1 is already attached to study 1."
562567

563568

569+
@pytest.mark.mut
564570
async def test_attach_task_to_study_but_task_not_exist_raises(
565571
py_api: httpx.AsyncClient,
566572
expdb_test: AsyncConnection,

0 commit comments

Comments
 (0)