Skip to content

Commit

Permalink
整理: e2e single API テスト vol 7 (#1165)
Browse files Browse the repository at this point in the history
* refactor: e2e single API スナップショットテストを追加

* fix: コメントフォーマット統一

* fix: format
  • Loading branch information
tarepan authored Apr 30, 2024
1 parent c0305ff commit 05478f7
Show file tree
Hide file tree
Showing 21 changed files with 210 additions and 18 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.

2 changes: 1 addition & 1 deletion test/e2e/single_api/__snapshots__/test_setting_api.ambr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# serializer version: 1
# name: test_setting画面が取得できる
# name: test_get_setting_200
'''
<!DOCTYPE html>

Expand Down

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.

6 changes: 5 additions & 1 deletion test/e2e/single_api/test_core_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"""

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


def test_get_core_versions_200(client: TestClient) -> None:
def test_get_core_versions_200(
client: TestClient, snapshot_json: SnapshotAssertion
) -> None:
response = client.get("/core_versions", params={})
assert response.status_code == 200
assert snapshot_json == response.json()
4 changes: 2 additions & 2 deletions test/e2e/single_api/test_engine_manifest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
/engine_manifest APIのテスト
/engine_manifest API のテスト
"""

from test.utility import hash_long_string
Expand All @@ -8,7 +8,7 @@
from syrupy.assertion import SnapshotAssertion


def test_エンジンマニフェストを取得できる(
def test_get_engine_manifest_200(
client: TestClient, snapshot_json: SnapshotAssertion
) -> None:
response = client.get("/engine_manifest")
Expand Down
1 change: 1 addition & 0 deletions test/e2e/single_api/test_initialize_speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
def test_post_initialize_speaker_204(client: TestClient) -> None:
response = client.post("/initialize_speaker", params={"speaker": 0})
assert response.status_code == 204
# `204 No Content` であるためスナップショットテストは不要
6 changes: 5 additions & 1 deletion test/e2e/single_api/test_is_initialized_speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"""

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


def test_get_is_initialized_speaker_200(client: TestClient) -> None:
def test_get_is_initialized_speaker_200(
client: TestClient, snapshot_json: SnapshotAssertion
) -> None:
response = client.get("/is_initialized_speaker", params={"speaker": 0})
assert response.status_code == 200
assert snapshot_json == response.json()
7 changes: 3 additions & 4 deletions test/e2e/single_api/test_setting_api.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"""
setting APIのテスト
/setting API のテスト
"""

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


def test_setting画面が取得できる(
client: TestClient, snapshot: SnapshotAssertion
) -> None:
def test_get_setting_200(client: TestClient, snapshot: SnapshotAssertion) -> None:
response = client.get("/setting")
assert response.status_code == 200
# HTML string をテスト
assert snapshot == response.content.decode("utf-8")
8 changes: 7 additions & 1 deletion test/e2e/single_api/test_singer_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
/singer_info API のテスト
"""

from test.utility import hash_long_string

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


def test_get_singer_info_200(client: TestClient) -> None:
def test_get_singer_info_200(
client: TestClient, snapshot_json: SnapshotAssertion
) -> None:
response = client.get(
"/singer_info", params={"speaker_uuid": "b1a81618-b27b-40d2-b0ea-27a9ad408c4b"}
)
assert response.status_code == 200
assert snapshot_json == hash_long_string(response.json())
4 changes: 3 additions & 1 deletion test/e2e/single_api/test_singers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"""

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


def test_get_singers_200(client: TestClient) -> None:
def test_get_singers_200(client: TestClient, snapshot_json: SnapshotAssertion) -> None:
response = client.get("/singers", params={})
assert response.status_code == 200
assert snapshot_json == response.json()
8 changes: 7 additions & 1 deletion test/e2e/single_api/test_speaker_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
/speaker_info API のテスト
"""

from test.utility import hash_long_string

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


def test_get_speaker_info_200(client: TestClient) -> None:
def test_get_speaker_info_200(
client: TestClient, snapshot_json: SnapshotAssertion
) -> None:
response = client.get(
"/speaker_info", params={"speaker_uuid": "388f246b-8c41-4ac1-8e2d-5d79f3ff56d9"}
)
assert response.status_code == 200
assert snapshot_json == hash_long_string(response.json())
4 changes: 3 additions & 1 deletion test/e2e/single_api/test_speakers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"""

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


def test_get_speakers_200(client: TestClient) -> None:
def test_get_speakers_200(client: TestClient, snapshot_json: SnapshotAssertion) -> None:
response = client.get("/speakers", params={})
assert response.status_code == 200
assert snapshot_json == response.json()
6 changes: 5 additions & 1 deletion test/e2e/single_api/test_supported_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"""

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


def test_get_supported_devices_200(client: TestClient) -> None:
def test_get_supported_devices_200(
client: TestClient, snapshot_json: SnapshotAssertion
) -> None:
response = client.get("/supported_devices", params={})
assert response.status_code == 200
assert snapshot_json == response.json()
7 changes: 3 additions & 4 deletions test/e2e/single_api/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
"""

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

from voicevox_engine import __version__


def test_get_version_200(client: TestClient) -> None:
def test_get_version_200(client: TestClient, snapshot_json: SnapshotAssertion) -> None:
response = client.get("/version", params={})
assert response.status_code == 200
assert response.json() == __version__
assert snapshot_json == response.json()

0 comments on commit 05478f7

Please sign in to comment.