You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.8 KiB

from pathlib import Path
from voice_transcriptor.models import AppSettings, MediaInfo
from voice_transcriptor.ui.main_window import MainWindow
class Repository:
def __init__(self, root: Path): self.settings = AppSettings("model", "pt-BR", root)
def load(self): return self.settings, None
def save(self, settings): self.settings = settings
class Credentials:
def set_api_key(self, value): pass
class Probe:
def probe(self, path): return MediaInfo(path, 10, 60.0, "aac", "60", True, False)
class Preprocessor:
def preprocess(self, *args, **kwargs): raise AssertionError("not started")
def test_main_window_exposes_progress_and_cancel_controls(qtbot, tmp_path: Path) -> None:
window = MainWindow(Probe(), Preprocessor(), Repository(tmp_path), Credentials())
qtbot.addWidget(window)
assert window.prepare_button.text() == "Prepare audio"
assert window.cancel_button.text() == "Cancel"
assert window.cancel_button.isEnabled() is False
assert window.progress_bar.value() == 0
def test_select_file_populates_media_and_enables_preprocessing(qtbot, tmp_path: Path) -> None:
source = tmp_path / "recording.mp3"; source.write_bytes(b"x")
window = MainWindow(Probe(), Preprocessor(), Repository(tmp_path), Credentials())
qtbot.addWidget(window)
window.select_file(source)
assert window.selected_media.path == source
assert window.prepare_button.isEnabled() is True
assert "recording.mp3" in window.file_label.text()
def test_cancel_button_cancels_active_token(qtbot, tmp_path: Path) -> None:
window = MainWindow(Probe(), Preprocessor(), Repository(tmp_path), Credentials())
qtbot.addWidget(window)
window._begin_busy_state()
window.cancel_preprocessing()
assert window._cancellation_token.cancelled is True