更新bug
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import threading
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
|
||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
import pytest
|
||||
from PySide6.QtWidgets import QApplication, QFrame, QLabel, QPushButton, QVBoxLayout
|
||||
from PySide6.QtWidgets import QApplication, QDialog, QFrame, QLabel, QPushButton, QVBoxLayout
|
||||
|
||||
from doctor_workstation.ui import diagnosis_media
|
||||
from doctor_workstation.ui.diagnosis_drawer import RecordTable
|
||||
@@ -378,6 +380,7 @@ def test_video_table_embeds_player_and_preserves_row_bound_upload(
|
||||
[
|
||||
{
|
||||
"id": 48,
|
||||
"room_id": "doctor-501-20260819-143247",
|
||||
"recording_urls_list": [
|
||||
"https://media.example.invalid/replay.mp4",
|
||||
"https://media.example.invalid/replay-backup.m3u8",
|
||||
@@ -407,6 +410,12 @@ def test_video_table_embeds_player_and_preserves_row_bound_upload(
|
||||
application.processEvents()
|
||||
|
||||
table = dialog._table_registry["video"][1]
|
||||
assert table.horizontalHeaderItem(1).text() == "房间号"
|
||||
assert table.item(0, 1).text() == "doctor-501-20260819-143247"
|
||||
assert table.item(1, 1).text() == "历史记录未保存"
|
||||
room_rect = table.visualItemRect(table.item(0, 1))
|
||||
assert room_rect.left() >= 0
|
||||
assert room_rect.right() < table.viewport().width()
|
||||
playback = table.cellWidget(0, 0)
|
||||
assert isinstance(playback, RecordingPlaybackCell)
|
||||
assert playback.property("callRecordId") == 48
|
||||
@@ -465,6 +474,132 @@ def test_video_table_embeds_player_and_preserves_row_bound_upload(
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_video_table_exposes_local_audio_separately_from_cloud_video_and_text(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
dialog = DiagnosisDialog(_Repository(), permissions=["*"])
|
||||
dialog._editable = False
|
||||
dialog._can_video_upload = False
|
||||
dialog._diagnosis_id = 501
|
||||
opened: list[str] = []
|
||||
dialog._open_recording_player = lambda target: opened.append(target) # type: ignore[method-assign]
|
||||
audio_url = "https://cos.example.invalid/calls/local-audio.webm"
|
||||
dialog._fill_video(
|
||||
[
|
||||
{
|
||||
"id": 49,
|
||||
"recording_urls_list": [
|
||||
"https://cos.example.invalid/calls/cloud-mixed-video.mp4"
|
||||
],
|
||||
"local_audio_urls_list": [audio_url],
|
||||
"local_audio_status_text": "已保存",
|
||||
"transcript_text": "医生:请描述症状。\n患者:最近口渴。",
|
||||
"transcription_status_text": "已完成",
|
||||
"call_type": 2,
|
||||
"status": 2,
|
||||
"recording_status_text": "已生成",
|
||||
}
|
||||
]
|
||||
)
|
||||
table = dialog._table_registry["video"][1]
|
||||
action_host = table.cellWidget(0, 8)
|
||||
assert action_host is not None
|
||||
audio = action_host.findChild(QPushButton, "DiagnosisLocalAudioPlayback")
|
||||
transcript = action_host.findChild(QPushButton, "DiagnosisVideoTranscriptView")
|
||||
assert audio is not None and audio.property("callRecordId") == 49
|
||||
assert transcript is not None and transcript.property("callRecordId") == 49
|
||||
status = table.item(0, 7).text()
|
||||
assert "云端视频:已生成" in status
|
||||
assert "本机录音:已保存" in status
|
||||
assert "转写文字:已完成" in status
|
||||
|
||||
audio.click()
|
||||
assert opened == [audio_url]
|
||||
dialog.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_local_audio_upload_and_queue_close_refresh_server_backed_video_rows(
|
||||
application: QApplication,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
created: list[QDialog] = []
|
||||
|
||||
class _UploadManager:
|
||||
def __init__(self) -> None:
|
||||
self.listeners: set[Any] = set()
|
||||
|
||||
def add_upload_listener(self, listener: Any) -> None:
|
||||
self.listeners.add(listener)
|
||||
|
||||
def remove_upload_listener(self, listener: Any) -> None:
|
||||
self.listeners.discard(listener)
|
||||
|
||||
def complete(self, diagnosis_id: int, call_record_id: int) -> None:
|
||||
record = SimpleNamespace(
|
||||
diagnosis_id=diagnosis_id,
|
||||
call_record_id=call_record_id,
|
||||
)
|
||||
for listener in tuple(self.listeners):
|
||||
listener(record)
|
||||
|
||||
manager = _UploadManager()
|
||||
|
||||
class _QueueDialog(QDialog):
|
||||
def __init__(
|
||||
self,
|
||||
_repository: Any,
|
||||
_diagnosis_id: int,
|
||||
parent: QDialog,
|
||||
) -> None:
|
||||
super().__init__(parent)
|
||||
self.manager = manager
|
||||
created.append(self)
|
||||
|
||||
monkeypatch.setattr(diagnosis_module, "LocalAudioQueueDialog", _QueueDialog)
|
||||
dialog = DiagnosisDialog(_Repository(), permissions=["*"])
|
||||
dialog._diagnosis_id = 501
|
||||
dialog._can_video_upload = True
|
||||
reloads: list[tuple[str, bool]] = []
|
||||
dialog._ensure_tab_loaded = ( # type: ignore[method-assign]
|
||||
lambda key, force=False: reloads.append((key, force))
|
||||
)
|
||||
|
||||
dialog._open_local_audio_queue()
|
||||
assert len(created) == 1
|
||||
queue_dialog = created[0]
|
||||
assert reloads == [("video", True)]
|
||||
|
||||
dialog._loading_tabs.add("video")
|
||||
manager.complete(501, 49)
|
||||
manager.complete(501, 50)
|
||||
manager.complete(999, 51)
|
||||
application.processEvents()
|
||||
assert reloads == [("video", True)]
|
||||
assert dialog._video_reload_pending is True
|
||||
|
||||
dialog._loading_tabs.discard("video")
|
||||
dialog._flush_video_reload_if_pending(501)
|
||||
application.processEvents()
|
||||
assert reloads == [("video", True), ("video", True)]
|
||||
|
||||
queue_dialog.accept()
|
||||
application.processEvents()
|
||||
assert reloads == [("video", True), ("video", True)]
|
||||
assert manager.listeners
|
||||
|
||||
worker = threading.Thread(target=lambda: manager.complete(501, 52))
|
||||
worker.start()
|
||||
worker.join(timeout=5)
|
||||
assert worker.is_alive() is False
|
||||
application.processEvents()
|
||||
assert reloads == [("video", True), ("video", True), ("video", True)]
|
||||
|
||||
dialog.reject()
|
||||
application.processEvents()
|
||||
assert manager.listeners == set()
|
||||
|
||||
|
||||
def test_inline_player_rejects_stale_owner_generation(application: QApplication) -> None:
|
||||
class _Owner:
|
||||
_tab_generations = {"video": 4}
|
||||
|
||||
Reference in New Issue
Block a user