Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

整理: e2e single API テスト vol 6 #1155

Merged
merged 5 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions test/e2e/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import shutil
from pathlib import Path
from typing import Any

Expand All @@ -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)
tarepan marked this conversation as resolved.
Show resolved Hide resolved
preset_manager = PresetManager(preset_path=Path(preset_path))

return {
"tts_engines": tts_engines,
"cores": cores,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions test/e2e/single_api/__snapshots__/test_delete_preset.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# serializer version: 1
# name: test_post_delete_preset_204
b''
# ---

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions test/e2e/single_api/test_add_preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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()
6 changes: 2 additions & 4 deletions test/e2e/single_api/test_delete_preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/single_api/test_update_preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
Expand Down
Loading