diff --git a/test/e2e/conftest.py b/test/e2e/conftest.py index ac6e0bb9d..353ccf6f7 100644 --- a/test/e2e/conftest.py +++ b/test/e2e/conftest.py @@ -1,3 +1,4 @@ +import shutil from pathlib import Path from typing import Any @@ -14,14 +15,18 @@ @pytest.fixture() -def app_params() -> dict[str, Any]: +def app_params(tmp_path: Path) -> dict[str, Any]: cores = initialize_cores(use_gpu=False, enable_mock=True) tts_engines = make_tts_engines_from_cores(cores) latest_core_version = get_latest_core_version(versions=list(tts_engines.keys())) setting_loader = SettingHandler(Path("./not_exist.yaml")) - preset_manager = PresetManager( # FIXME: impl MockPresetManager - preset_path=Path("./presets.yaml"), - ) + + # 隔離されたプリセットの生成 + original_preset_path = Path("./presets.yaml") + preset_path = tmp_path / "presets.yaml" + shutil.copyfile(original_preset_path, preset_path) + preset_manager = PresetManager(preset_path) + return { "tts_engines": tts_engines, "cores": cores, diff --git a/test/e2e/single_api/__snapshots__/test_add_preset/test_post_add_preset_200.json b/test/e2e/single_api/__snapshots__/test_add_preset/test_post_add_preset_200.json new file mode 100644 index 000000000..3c2df076c --- /dev/null +++ b/test/e2e/single_api/__snapshots__/test_add_preset/test_post_add_preset_200.json @@ -0,0 +1 @@ +9999 diff --git a/test/e2e/single_api/__snapshots__/test_delete_preset.ambr b/test/e2e/single_api/__snapshots__/test_delete_preset.ambr new file mode 100644 index 000000000..aed06a4e5 --- /dev/null +++ b/test/e2e/single_api/__snapshots__/test_delete_preset.ambr @@ -0,0 +1,4 @@ +# serializer version: 1 +# name: test_post_delete_preset_204 + b'' +# --- diff --git a/test/e2e/single_api/__snapshots__/test_update_preset/test_post_update_preset_200.json b/test/e2e/single_api/__snapshots__/test_update_preset/test_post_update_preset_200.json new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/test/e2e/single_api/__snapshots__/test_update_preset/test_post_update_preset_200.json @@ -0,0 +1 @@ +1 diff --git a/test/e2e/single_api/test_add_preset.py b/test/e2e/single_api/test_add_preset.py index 769bcfe69..c352812ad 100644 --- a/test/e2e/single_api/test_add_preset.py +++ b/test/e2e/single_api/test_add_preset.py @@ -2,12 +2,13 @@ /add_preset API のテスト """ -import pytest from fastapi.testclient import TestClient +from syrupy.assertion import SnapshotAssertion -@pytest.mark.skip(reason="プリセット追加が他のテストに干渉するから") -def test_post_add_preset_200(client: TestClient) -> None: +def test_post_add_preset_200( + client: TestClient, snapshot_json: SnapshotAssertion +) -> None: preset = { "id": 9999, "name": "test_preset", @@ -22,3 +23,4 @@ def test_post_add_preset_200(client: TestClient) -> None: } response = client.post("/add_preset", params={}, json=preset) assert response.status_code == 200 + assert snapshot_json == response.json() diff --git a/test/e2e/single_api/test_delete_preset.py b/test/e2e/single_api/test_delete_preset.py index 0baa3bd76..bebed0e3f 100644 --- a/test/e2e/single_api/test_delete_preset.py +++ b/test/e2e/single_api/test_delete_preset.py @@ -2,18 +2,16 @@ /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 + client: TestClient, snapshot: SnapshotAssertion ) -> None: response = client.post("/delete_preset", params={"id": 1}) assert response.status_code == 204 - assert snapshot_json == response.json() + assert snapshot == response.content def test_post_delete_preset_422( diff --git a/test/e2e/single_api/test_update_preset.py b/test/e2e/single_api/test_update_preset.py index 957bd0854..e5dc18821 100644 --- a/test/e2e/single_api/test_update_preset.py +++ b/test/e2e/single_api/test_update_preset.py @@ -2,13 +2,13 @@ /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: +def test_post_update_preset_200( + client: TestClient, snapshot_json: SnapshotAssertion +) -> None: preset = { "id": 1, "name": "test_preset", @@ -23,6 +23,7 @@ def test_post_update_preset_200(client: TestClient) -> None: } response = client.post("/update_preset", params={}, json=preset) assert response.status_code == 200 + assert snapshot_json == response.json() def test_post_update_preset_422(