-
Notifications
You must be signed in to change notification settings - Fork 208
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
jsonschemaでaudio_queryのレスポンスのバリデーションをしました。 #739
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
スキーマのバリデーションをするの良いですね!!
FastAPIは内部でpydanticというのを使っていて、Pythonの型サポートの恩恵を受けつつスキーマを書けるので便利かもです。
AudioQueryのVOICEVOXでの定義はここにあります。
voicevox_engine/voicevox_engine/model.py
Line 48 in 7b63baa
class AudioQuery(BaseModel): |
またpydanticは
parase_obj
でvalidateっぽいこともできそうです。なので今回のコードはこんな感じでも書けるかも?
from generate_test_client import client
from voicevox_engine.model import AudioQuery
def test_fetch_version_success():
response = client.post("/audio_query?text=こんにちは&speaker=0")
assert response.status_code == 200
AudioQuery.parse_obj(response.json())
from jsonschema import validate | ||
|
||
|
||
def test_fetch_version_success(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
関数名を変え忘れているかもです
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 機能性を担保するe2eテストの導入により開発の安全性が向上しています。good work!
@Hiroshiba
後続の #967 にて同様の e2e テストが導入されたため、このPRは歴史的役割を終えたかと思います。
close が適切そうです。
内容
関連 Issue
ref #730
スクリーンショット・動画など
その他