Skip to content

Commit

Permalink
Finish happy path test for creating a study
Browse files Browse the repository at this point in the history
  • Loading branch information
PGijsbers committed Dec 19, 2023
1 parent 37a25c8 commit 7124e80
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion tests/routers/openml/study_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import datetime

from starlette.testclient import TestClient


Expand Down Expand Up @@ -450,7 +452,7 @@ def test_get_task_study_by_alias(py_api: TestClient) -> None:


def test_create_task_study(py_api: TestClient) -> None:
py_api.post(
response = py_api.post(
"/studies?api_key=00000000000000000000000000000000",
json={
"name": "Test Study",
Expand All @@ -461,3 +463,34 @@ def test_create_task_study(py_api: TestClient) -> None:
"runs": [],
},
)
assert response.status_code == 200
new = response.json()
assert "study_id" in new
study_id = new["study_id"]
assert isinstance(study_id, int)

study = py_api.get(f"/studies/{study_id}")
assert study.status_code == 200
expected = {
"id": study_id,
"alias": "test-study",
"main_entity_type": "task",
"name": "Test Study",
"description": "A test study",
"visibility": "public",
"status": "in_preparation",
"creator": 2,
"data_ids": [1, 1, 1],
"task_ids": [1, 2, 3],
"run_ids": [],
"flow_ids": [],
"setup_ids": [],
}
new_study = study.json()

creation_date = datetime.strptime(
new_study.pop("creation_date"),
"%Y-%m-%dT%H:%M:%S",
)
assert creation_date.date() == datetime.now().date()
assert new_study == expected

0 comments on commit 7124e80

Please sign in to comment.