147 lines
5.8 KiB
Python
147 lines
5.8 KiB
Python
import pytest
|
|
|
|
|
|
async def test_task_capabilities_reads_nested_source_certificate(system, monkeypatch):
|
|
from app.adapters.provider import dialogue_gpu as gpu
|
|
|
|
system.settings.dialogue_lipsync_enabled = True
|
|
key = gpu.KEYS[gpu.SYNC]
|
|
legacy = dict(
|
|
available=True,
|
|
profile=gpu.profile(gpu.SYNC),
|
|
task_type=gpu.SYNC,
|
|
decision="pass",
|
|
adapter_contract_version="dialogue-v1",
|
|
speech_silence_policy=gpu.SILENCE_POLICY,
|
|
mouth_blend_policy=gpu.MOUTH_BLEND_POLICY,
|
|
audio_context_shift_policy=gpu.AUDIO_CONTEXT_SHIFT_POLICY,
|
|
revision=gpu.REVISIONS[gpu.SYNC],
|
|
report_sha256="a" * 64,
|
|
max_people=1,
|
|
)
|
|
source = {**legacy, "speech_silence_policy": gpu.SOURCE_REST_POLICY, "max_people": 2}
|
|
policies = {gpu.SILENCE_POLICY: {key: legacy}, gpu.SOURCE_REST_POLICY: {key: source}}
|
|
|
|
async def snapshot():
|
|
return {"dialogue": {key: legacy, "silence_policies": policies}}
|
|
|
|
monkeypatch.setattr(system.provider, "upstream_capabilities", snapshot, raising=False)
|
|
|
|
async def item():
|
|
rows = (await system.client.get("/api/capabilities")).json()["items"]
|
|
return next(row for row in rows if row["task_type"] == gpu.SYNC)
|
|
|
|
ready = await item()
|
|
assert ready["available"] and ready["constraints"]["max_people"] == 2
|
|
policies[gpu.SOURCE_REST_POLICY][key] = legacy
|
|
assert not (await item())["available"]
|
|
del policies[gpu.SOURCE_REST_POLICY]
|
|
assert not (await item())["available"]
|
|
|
|
|
|
async def test_dialogue_authoring_available_but_generation_requires_certificates(system):
|
|
system.settings.dialogue_lipsync_enabled = True
|
|
system.settings.dialogue_speech_enabled = True
|
|
system.settings.dialogue_quality_certified = True
|
|
response = await system.client.get("/api/capabilities")
|
|
assert response.status_code == 200
|
|
result = response.json()
|
|
assert result["dialogue"]["authoring_available"] is True
|
|
assert result["dialogue"]["production_available"] is False
|
|
assert result["dialogue"]["supports_single_face"] is False
|
|
assert 3 in result["editable_production"]["supported_schema_versions"]
|
|
assert 5 in result["editable_production"]["story_schema_versions"]
|
|
tasks = {item["task_type"]: item for item in result["items"]}
|
|
assert tasks["video.lipsync"]["available"] is False
|
|
|
|
|
|
async def test_legacy_musetalk_certificates_cannot_enable_native_production(system, monkeypatch):
|
|
from app.services import system as service
|
|
|
|
system.settings.dialogue_quality_certified = True
|
|
system.settings.dialogue_two_faces_enabled = True
|
|
audio_ready = False
|
|
|
|
async def tasks(runtime):
|
|
return [
|
|
{
|
|
"task_type": name,
|
|
"available": audio_ready if name == "audio.dialogue.inspect" else True,
|
|
"constraints": {"max_people": 1 if name == "audio.dialogue.inspect" else 2},
|
|
}
|
|
for name in (
|
|
"video.dialogue.analyze",
|
|
"video.lipsync",
|
|
"video.dialogue.inspect",
|
|
"audio.dialogue.inspect",
|
|
)
|
|
]
|
|
|
|
monkeypatch.setattr(service, "task_capabilities", tasks)
|
|
unavailable = (await system.client.get("/api/capabilities")).json()["dialogue"]
|
|
assert unavailable["production_available"] is False
|
|
audio_ready = True
|
|
ready = (await system.client.get("/api/capabilities")).json()["dialogue"]
|
|
assert ready["production_available"] is False
|
|
assert ready["supports_two_faces"] is False
|
|
|
|
|
|
async def test_native_production_requires_its_own_generation_and_word_alignment_certificates(
|
|
system,
|
|
):
|
|
from test_native_av_contract import certificate, alignment_certificate
|
|
|
|
system.settings.native_dialogue_enabled = True
|
|
system.settings.dialogue_quality_certified = True
|
|
system.settings.dialogue_lipsync_enabled = False
|
|
system.settings.dialogue_speech_enabled = False
|
|
native_alignment = alignment_certificate()
|
|
|
|
async def snapshot():
|
|
return {
|
|
"video_generation": {"native_av": certificate()},
|
|
"dialogue": {
|
|
"speech_inspect": {"available": False, "native_alignment": native_alignment}
|
|
},
|
|
}
|
|
|
|
system.provider.upstream_capabilities = snapshot
|
|
response = await system.client.get("/api/capabilities")
|
|
assert response.status_code == 200
|
|
dialogue = response.json()["dialogue"]
|
|
assert dialogue["production_available"] is True
|
|
assert dialogue["native_av"]["available"] is True
|
|
assert dialogue["supports_two_faces"] is False
|
|
native_alignment["available"] = False
|
|
unavailable = (await system.client.get("/api/capabilities")).json()["dialogue"]
|
|
assert unavailable["production_available"] is False
|
|
|
|
|
|
@pytest.mark.parametrize("missing", ["visual_certificate", "qwen_url", "qwen_model"])
|
|
async def test_native_readiness_requires_visual_review_before_enabling_production(system, missing):
|
|
from test_native_av_contract import certificate, alignment_certificate
|
|
|
|
system.settings.native_dialogue_enabled = True
|
|
system.settings.dialogue_quality_certified = missing != "visual_certificate"
|
|
if missing == "qwen_url":
|
|
system.settings.qwen_base_url = ""
|
|
elif missing == "qwen_model":
|
|
system.settings.qwen_model = ""
|
|
|
|
async def snapshot():
|
|
return {
|
|
"video_generation": {"native_av": certificate()},
|
|
"dialogue": {"speech_inspect": {"native_alignment": alignment_certificate()}},
|
|
}
|
|
|
|
system.provider.upstream_capabilities = snapshot
|
|
data = (await system.client.get("/api/capabilities")).json()
|
|
dialogue = data["dialogue"]
|
|
assert dialogue["available"] is False
|
|
assert dialogue["production_available"] is False
|
|
assert dialogue["native_av"]["available"] is False
|
|
assert dialogue["native_av"]["readiness"] == dict(
|
|
generation=True, word_alignment=True, visual_review=False
|
|
)
|
|
assert "画面" in dialogue["reason"]
|