diff --git a/test/e2e/single_api/__snapshots__/test_delete_preset/test_post_delete_preset_422.json b/test/e2e/single_api/__snapshots__/test_delete_preset/test_post_delete_preset_422.json new file mode 100644 index 000000000..daaa6995e --- /dev/null +++ b/test/e2e/single_api/__snapshots__/test_delete_preset/test_post_delete_preset_422.json @@ -0,0 +1,3 @@ +{ + "detail": "削除対象のプリセットが存在しません" +} diff --git "a/test/e2e/single_api/__snapshots__/test_preset_api/test_\343\203\227\343\203\252\343\202\273\343\203\203\343\203\210\344\270\200\350\246\247\343\202\222\345\217\226\345\276\227\343\201\247\343\201\215\343\202\213.json" b/test/e2e/single_api/__snapshots__/test_presets/test_get_presets_200.json similarity index 100% rename from "test/e2e/single_api/__snapshots__/test_preset_api/test_\343\203\227\343\203\252\343\202\273\343\203\203\343\203\210\344\270\200\350\246\247\343\202\222\345\217\226\345\276\227\343\201\247\343\201\215\343\202\213.json" rename to test/e2e/single_api/__snapshots__/test_presets/test_get_presets_200.json diff --git a/test/e2e/single_api/__snapshots__/test_update_preset/test_post_update_preset_422.json b/test/e2e/single_api/__snapshots__/test_update_preset/test_post_update_preset_422.json new file mode 100644 index 000000000..f95655e5e --- /dev/null +++ b/test/e2e/single_api/__snapshots__/test_update_preset/test_post_update_preset_422.json @@ -0,0 +1,3 @@ +{ + "detail": "更新先のプリセットが存在しません" +} diff --git a/test/e2e/single_api/test_add_preset.py b/test/e2e/single_api/test_add_preset.py new file mode 100644 index 000000000..769bcfe69 --- /dev/null +++ b/test/e2e/single_api/test_add_preset.py @@ -0,0 +1,24 @@ +""" +/add_preset API のテスト +""" + +import pytest +from fastapi.testclient import TestClient + + +@pytest.mark.skip(reason="プリセット追加が他のテストに干渉するから") +def test_post_add_preset_200(client: TestClient) -> None: + preset = { + "id": 9999, + "name": "test_preset", + "speaker_uuid": "123-456-789-234", + "style_id": 9999, + "speedScale": 1, + "pitchScale": 1, + "intonationScale": 1, + "volumeScale": 1, + "prePhonemeLength": 10, + "postPhonemeLength": 10, + } + response = client.post("/add_preset", params={}, json=preset) + assert response.status_code == 200 diff --git a/test/e2e/single_api/test_delete_preset.py b/test/e2e/single_api/test_delete_preset.py new file mode 100644 index 000000000..0baa3bd76 --- /dev/null +++ b/test/e2e/single_api/test_delete_preset.py @@ -0,0 +1,24 @@ +""" +/delete_preset API のテスト +""" + +import pytest +from fastapi.testclient import TestClient +from syrupy.assertion import SnapshotAssertion + + +@pytest.mark.skip(reason="プリセット削除が他のテストに干渉するから") +def test_post_delete_preset_204( + client: TestClient, snapshot_json: SnapshotAssertion +) -> None: + response = client.post("/delete_preset", params={"id": 1}) + assert response.status_code == 204 + assert snapshot_json == response.json() + + +def test_post_delete_preset_422( + client: TestClient, snapshot_json: SnapshotAssertion +) -> None: + response = client.post("/delete_preset", params={"id": 4040000000}) + assert response.status_code == 422 + assert snapshot_json == response.json() diff --git a/test/e2e/single_api/test_preset_api.py b/test/e2e/single_api/test_presets.py similarity index 59% rename from test/e2e/single_api/test_preset_api.py rename to test/e2e/single_api/test_presets.py index 5dc816ec6..b8385ccc1 100644 --- a/test/e2e/single_api/test_preset_api.py +++ b/test/e2e/single_api/test_presets.py @@ -1,14 +1,12 @@ """ -プリセットAPIのテスト +/presets API のテスト """ from fastapi.testclient import TestClient from syrupy.assertion import SnapshotAssertion -def test_プリセット一覧を取得できる( - client: TestClient, snapshot_json: SnapshotAssertion -) -> None: +def test_get_presets_200(client: TestClient, snapshot_json: SnapshotAssertion) -> None: response = client.get("/presets") assert response.status_code == 200 assert snapshot_json == response.json() diff --git a/test/e2e/single_api/test_update_preset.py b/test/e2e/single_api/test_update_preset.py new file mode 100644 index 000000000..957bd0854 --- /dev/null +++ b/test/e2e/single_api/test_update_preset.py @@ -0,0 +1,45 @@ +""" +/update_preset API のテスト +""" + +import pytest +from fastapi.testclient import TestClient +from syrupy.assertion import SnapshotAssertion + + +@pytest.mark.skip(reason="プリセット変更が他のテストに干渉するから") +def test_post_update_preset_200(client: TestClient) -> None: + preset = { + "id": 1, + "name": "test_preset", + "speaker_uuid": "123-456-789-234", + "style_id": 9999, + "speedScale": 1, + "pitchScale": 1, + "intonationScale": 1, + "volumeScale": 1, + "prePhonemeLength": 10, + "postPhonemeLength": 10, + } + response = client.post("/update_preset", params={}, json=preset) + assert response.status_code == 200 + + +def test_post_update_preset_422( + client: TestClient, snapshot_json: SnapshotAssertion +) -> None: + preset = { + "id": 4040000000, + "name": "Nessie", + "speaker_uuid": "404-404-404-404", + "style_id": 404, + "speedScale": 404, + "pitchScale": 404, + "intonationScale": 404, + "volumeScale": 404, + "prePhonemeLength": 404, + "postPhonemeLength": 404, + } + response = client.post("/update_preset", params={}, json=preset) + assert response.status_code == 422 + assert snapshot_json == response.json()