Skip to content

Commit

Permalink
e2eテストのTestClientをfixtureにする (#737)
Browse files Browse the repository at this point in the history
* e2eテストのsessionをfixtureにする

* デグレってた

* isort

* default_setting.ymlに変更

* テストの実行方法をREADMEに追記
  • Loading branch information
Hiroshiba authored Sep 15, 2023
1 parent fe6fb5f commit 2b9e234
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ pre-commit install -t pre-push
pysen run format lint
```
## テスト
```bash
python -m pytest
```
## タイポチェック
[typos](https://github.com/crate-ci/typos) を使ってタイポのチェックを行っています。
Expand Down
24 changes: 24 additions & 0 deletions test/e2e/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from pathlib import Path

import pytest
from fastapi.testclient import TestClient
from run import generate_app

from voicevox_engine.setting import SettingLoader
from voicevox_engine.synthesis_engine import make_synthesis_engines
from voicevox_engine.utility.core_version_utility import get_latest_core_version


@pytest.fixture(scope="session")
def client():
synthesis_engines = make_synthesis_engines(use_gpu=False)
latest_core_version = get_latest_core_version(versions=synthesis_engines.keys())
setting_loader = SettingLoader(Path("./default_setting.yml"))

return TestClient(
generate_app(
synthesis_engines=synthesis_engines,
latest_core_version=latest_core_version,
setting_loader=setting_loader,
)
)
18 changes: 0 additions & 18 deletions test/e2e/generate_test_client.py

This file was deleted.

4 changes: 2 additions & 2 deletions test/e2e/test_validate_version.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from generate_test_client import client
from fastapi.testclient import TestClient

from voicevox_engine import __version__


def test_fetch_version_success():
def test_fetch_version_success(client: TestClient):
response = client.get("/version")
assert response.status_code == 200
assert response.json() == __version__

0 comments on commit 2b9e234

Please sign in to comment.