From e7df0c576c24d0ce3e9fcebe3d4013426997d169 Mon Sep 17 00:00:00 2001 From: tarepan Date: Sat, 30 Mar 2024 06:20:26 +0000 Subject: [PATCH 1/5] =?UTF-8?q?add:=20=E5=89=AF=E4=BD=9C=E7=94=A8=E7=84=A1?= =?UTF-8?q?=E3=81=97=E3=83=97=E3=83=AA=E3=82=BB=E3=83=83=E3=83=88=20e2e=20?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/e2e/conftest.py | 11 +++++++---- .../test_add_preset/test_post_add_preset_200.json | 1 + .../test_post_update_preset_200.json | 1 + test/e2e/single_api/test_add_preset.py | 6 +++--- test/e2e/single_api/test_delete_preset.py | 2 -- test/e2e/single_api/test_update_preset.py | 4 ++-- 6 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 test/e2e/single_api/__snapshots__/test_add_preset/test_post_add_preset_200.json create mode 100644 test/e2e/single_api/__snapshots__/test_update_preset/test_post_update_preset_200.json diff --git a/test/e2e/conftest.py b/test/e2e/conftest.py index ac6e0bb9d..1d74c3afd 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,16 @@ @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"), - ) + + # 隔離されたプリセットの生成 + preset_path = shutil.copy(Path("./presets.yaml"), tmp_path) + preset_manager = PresetManager(preset_path=Path(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_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..713e2f84f 100644 --- a/test/e2e/single_api/test_add_preset.py +++ b/test/e2e/single_api/test_add_preset.py @@ -2,12 +2,11 @@ /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 +21,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..829190f53 100644 --- a/test/e2e/single_api/test_delete_preset.py +++ b/test/e2e/single_api/test_delete_preset.py @@ -2,12 +2,10 @@ /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: diff --git a/test/e2e/single_api/test_update_preset.py b/test/e2e/single_api/test_update_preset.py index 957bd0854..4caa3b6d3 100644 --- a/test/e2e/single_api/test_update_preset.py +++ b/test/e2e/single_api/test_update_preset.py @@ -7,8 +7,7 @@ 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 +22,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( From 6da0ec4f0b74b894badb744a6e719b317384dca8 Mon Sep 17 00:00:00 2001 From: tarepan Date: Tue, 9 Apr 2024 04:39:30 +0000 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20204=E3=82=B9=E3=83=8A=E3=83=83?= =?UTF-8?q?=E3=83=97=E3=82=B7=E3=83=A7=E3=83=83=E3=83=88=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/e2e/single_api/__snapshots__/test_delete_preset.ambr | 4 ++++ test/e2e/single_api/test_delete_preset.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 test/e2e/single_api/__snapshots__/test_delete_preset.ambr 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/test_delete_preset.py b/test/e2e/single_api/test_delete_preset.py index 829190f53..bebed0e3f 100644 --- a/test/e2e/single_api/test_delete_preset.py +++ b/test/e2e/single_api/test_delete_preset.py @@ -7,11 +7,11 @@ 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( From ffaf3504f24eff59096e50838930f0f9355c80fa Mon Sep 17 00:00:00 2001 From: tarepan Date: Tue, 9 Apr 2024 04:42:07 +0000 Subject: [PATCH 3/5] fix: lint --- test/e2e/single_api/test_add_preset.py | 4 +++- test/e2e/single_api/test_update_preset.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/e2e/single_api/test_add_preset.py b/test/e2e/single_api/test_add_preset.py index 713e2f84f..c352812ad 100644 --- a/test/e2e/single_api/test_add_preset.py +++ b/test/e2e/single_api/test_add_preset.py @@ -6,7 +6,9 @@ from syrupy.assertion import SnapshotAssertion -def test_post_add_preset_200(client: TestClient, snapshot_json: SnapshotAssertion) -> None: +def test_post_add_preset_200( + client: TestClient, snapshot_json: SnapshotAssertion +) -> None: preset = { "id": 9999, "name": "test_preset", diff --git a/test/e2e/single_api/test_update_preset.py b/test/e2e/single_api/test_update_preset.py index 4caa3b6d3..e735dfb27 100644 --- a/test/e2e/single_api/test_update_preset.py +++ b/test/e2e/single_api/test_update_preset.py @@ -7,7 +7,9 @@ from syrupy.assertion import SnapshotAssertion -def test_post_update_preset_200(client: TestClient, snapshot_json: SnapshotAssertion) -> None: +def test_post_update_preset_200( + client: TestClient, snapshot_json: SnapshotAssertion +) -> None: preset = { "id": 1, "name": "test_preset", From 75822bf2f3ab5b6a41404b19c43ebab02e9100fc Mon Sep 17 00:00:00 2001 From: tarepan Date: Tue, 9 Apr 2024 04:42:27 +0000 Subject: [PATCH 4/5] fix: lint --- test/e2e/single_api/test_update_preset.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/single_api/test_update_preset.py b/test/e2e/single_api/test_update_preset.py index e735dfb27..e5dc18821 100644 --- a/test/e2e/single_api/test_update_preset.py +++ b/test/e2e/single_api/test_update_preset.py @@ -2,7 +2,6 @@ /update_preset API のテスト """ -import pytest from fastapi.testclient import TestClient from syrupy.assertion import SnapshotAssertion From c2554a60955280e01710f1dd8e0409ce96c52e04 Mon Sep 17 00:00:00 2001 From: tarepan Date: Wed, 10 Apr 2024 04:12:41 +0000 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E3=83=97=E3=83=AA=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=83=88=E8=A4=87=E8=A3=BD=E3=82=92=E5=B9=B3=E6=98=93=E3=81=AA?= =?UTF-8?q?=E8=A8=98=E6=B3=95=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/e2e/conftest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/e2e/conftest.py b/test/e2e/conftest.py index 1d74c3afd..353ccf6f7 100644 --- a/test/e2e/conftest.py +++ b/test/e2e/conftest.py @@ -22,8 +22,10 @@ def app_params(tmp_path: Path) -> dict[str, Any]: setting_loader = SettingHandler(Path("./not_exist.yaml")) # 隔離されたプリセットの生成 - preset_path = shutil.copy(Path("./presets.yaml"), tmp_path) - preset_manager = PresetManager(preset_path=Path(preset_path)) + 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,