Skip to content

Commit

Permalink
整理: e2e single API スナップショットテスト vol.1 (#1117)
Browse files Browse the repository at this point in the history
* add: e2e single API スナップショットテスト

* fix: lint

* fix: 過剰な `round_floats()` の削除
  • Loading branch information
tarepan authored Mar 18, 2024
1 parent fb5b086 commit 6d1fb0f
Show file tree
Hide file tree
Showing 16 changed files with 350 additions and 9 deletions.

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

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

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

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

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

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

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

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

8 changes: 7 additions & 1 deletion test/e2e/single_api/test_accent_phrases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
/accent_phrases API のテスト
"""

from test.utility import round_floats

from fastapi.testclient import TestClient
from syrupy.assertion import SnapshotAssertion


def test_post_accent_phrases_200(client: TestClient) -> None:
def test_post_accent_phrases_200(
client: TestClient, snapshot_json: SnapshotAssertion
) -> None:
response = client.post(
"/accent_phrases", params={"text": "テストです", "speaker": 0}
)
assert response.status_code == 200
assert snapshot_json == round_floats(response.json(), 2)
13 changes: 11 additions & 2 deletions test/e2e/single_api/test_audio_query_from_preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@
/audio_query_from_preset API のテスト
"""

from test.utility import round_floats

import pytest
from fastapi.testclient import TestClient
from syrupy.assertion import SnapshotAssertion


@pytest.mark.skip(reason="200の前提として別APIを要するプリセット登録が必要だから")
def test_post_audio_query_from_preset_200(client: TestClient) -> None:
def test_post_audio_query_from_preset_200(
client: TestClient, snapshot_json: SnapshotAssertion
) -> None:
response = client.post(
"/audio_query_from_preset", params={"text": "テストです", "preset_id": 0}
)
assert response.status_code == 200
assert snapshot_json == round_floats(response.json(), 2)


def test_post_audio_query_from_preset_422(client: TestClient) -> None:
def test_post_audio_query_from_preset_422(
client: TestClient, snapshot_json: SnapshotAssertion
) -> None:
response = client.post(
"/audio_query_from_preset", params={"text": "テストです", "preset_id": 404}
)
assert response.status_code == 422
assert snapshot_json == response.json()
7 changes: 6 additions & 1 deletion test/e2e/single_api/test_mora_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
"""

from test.e2e.single_api.utils import gen_mora
from test.utility import round_floats

from fastapi.testclient import TestClient
from syrupy.assertion import SnapshotAssertion


def test_post_mora_data_200(client: TestClient) -> None:
def test_post_mora_data_200(
client: TestClient, snapshot_json: SnapshotAssertion
) -> None:
accent_phrases = [
{
"moras": [
Expand All @@ -22,3 +26,4 @@ def test_post_mora_data_200(client: TestClient) -> None:
]
response = client.post("/mora_data", params={"speaker": 0}, json=accent_phrases)
assert response.status_code == 200
assert snapshot_json == round_floats(response.json(), 2)
7 changes: 6 additions & 1 deletion test/e2e/single_api/test_mora_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
"""

from test.e2e.single_api.utils import gen_mora
from test.utility import round_floats

from fastapi.testclient import TestClient
from syrupy.assertion import SnapshotAssertion


def test_post_mora_length_200(client: TestClient) -> None:
def test_post_mora_length_200(
client: TestClient, snapshot_json: SnapshotAssertion
) -> None:
accent_phrases = [
{
"moras": [
Expand All @@ -22,3 +26,4 @@ def test_post_mora_length_200(client: TestClient) -> None:
]
response = client.post("/mora_length", params={"speaker": 0}, json=accent_phrases)
assert response.status_code == 200
assert snapshot_json == round_floats(response.json(), 2)
Loading

0 comments on commit 6d1fb0f

Please sign in to comment.