will / tests /test_ui_gradio.py
matt1847's picture
機能追加: モデルラインナップ拡張とGradio UI移行
f94169f
"""
Gradio UI関連のテスト
"""
import pytest
class TestGradioApp:
"""Gradio UIのテスト"""
def test_import_gradio_app(self):
"""Gradioアプリがインポートできることを確認"""
from src.ui.gradio.app import create_app
assert create_app is not None
def test_create_app_returns_blocks(self):
"""create_appがGradio Blocksを返すことを確認"""
import gradio as gr
from src.ui.gradio.app import create_app
app = create_app()
assert isinstance(app, gr.Blocks)
def test_generate_debris_function_exists(self):
"""generate_debris関数が存在することを確認"""
from src.ui.gradio.app import generate_debris
assert callable(generate_debris)
def test_generate_debris_returns_tuple(self):
"""generate_debris関数がタプルを返すことを確認"""
from src.ui.gradio.app import generate_debris
# GPT-2 Small(最小モデル)でテスト
result = generate_debris("gpt2")
# (image, debris_text, seed_text) の3要素タプル
assert isinstance(result, tuple)
assert len(result) == 3
class TestGradioAppModelSelection:
"""モデル選択のテスト"""
def test_get_model_choices(self):
"""モデル選択肢が取得できることを確認"""
from src.ui.gradio.app import get_model_choices
choices = get_model_choices()
assert len(choices) > 0
# (表示名, キー) のタプルリスト
assert all(isinstance(c, tuple) and len(c) == 2 for c in choices)
def test_model_choices_include_new_models(self):
"""新モデルが選択肢に含まれることを確認"""
from src.ui.gradio.app import get_model_choices
choices = get_model_choices()
keys = [c[1] for c in choices]
# 新モデルが含まれることを確認
assert "gpt-oss-20b" in keys
assert "pythia-410m" in keys
assert "qwen2.5-0.5b" in keys