mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-11 19:06:11 +00:00
Merge master into the macOS front branch
This commit is contained in:
+70
-3
@@ -16,12 +16,16 @@ from PyQt6.QtCore import QPoint, QPointF, Qt
|
||||
from PyQt6.QtGui import QWheelEvent
|
||||
from PyQt6.QtWidgets import QApplication, QMessageBox
|
||||
|
||||
from dikte import audio
|
||||
from dikte import cleanup
|
||||
from dikte import config as cfg
|
||||
from dikte import ggml
|
||||
from dikte import hotkey
|
||||
from dikte import ipc
|
||||
from dikte import overlay as overlay_module
|
||||
from dikte import paste
|
||||
from dikte import settings_ui
|
||||
from dikte import update
|
||||
from tests.support import DikteTest, only_these_tools
|
||||
|
||||
# One application for the whole run; Qt allows no second one.
|
||||
@@ -100,6 +104,7 @@ CHANGED = {
|
||||
"pause_shortcut": "Meta+P",
|
||||
"evdev_hotkey": True,
|
||||
"history_limit": 50,
|
||||
"update_check": False,
|
||||
}
|
||||
|
||||
|
||||
@@ -249,6 +254,31 @@ class Settings(DikteTest):
|
||||
self.assertEqual(shown, [provider])
|
||||
self.assertFalse(box.isHidden())
|
||||
|
||||
def test_the_update_line_names_the_version_that_is_running(self):
|
||||
window = self.window(cfg.Config())
|
||||
self.assertIn(settings_ui.__version__, window.update_status.text())
|
||||
# Nothing to open until a check has found something to open.
|
||||
self.assertTrue(window.update_page.isHidden())
|
||||
|
||||
def test_a_newer_release_puts_the_page_button_on_screen(self):
|
||||
window = self.window(cfg.Config())
|
||||
told = []
|
||||
window.update_found.connect(told.append)
|
||||
release = update.Release("9.9.9", "https://example.invalid/9.9.9", "")
|
||||
window._on_update_checked(release, "")
|
||||
self.assertIn("9.9.9", window.update_status.text())
|
||||
self.assertFalse(window.update_page.isHidden())
|
||||
self.assertEqual(window._release_url, release.url)
|
||||
# And the tray hears about it from here rather than waiting a day.
|
||||
self.assertEqual(told, [release])
|
||||
|
||||
def test_a_check_that_failed_says_why_and_hands_the_button_back(self):
|
||||
window = self.window(cfg.Config())
|
||||
window.update_now.setEnabled(False)
|
||||
window._on_update_checked(None, "api.github.com answered HTTP 403.")
|
||||
self.assertIn("403", window.update_status.text())
|
||||
self.assertTrue(window.update_now.isEnabled())
|
||||
|
||||
def test_the_settings_the_window_does_not_show_are_left_alone(self):
|
||||
"""A tab nobody wrote must not reset what the command line set."""
|
||||
self.write_config({"silence_db": -42.0, "speech_margin_db": 15.0,
|
||||
@@ -281,7 +311,7 @@ class Settings(DikteTest):
|
||||
text = self.shortcut_tab_text(window)
|
||||
self.assertIn("i3 keeps no shortcut registry", text)
|
||||
self.assertNotIn("KWin", text)
|
||||
self.assertIn("__main__.py toggle", text)
|
||||
self.assertIn(ipc.command_for("toggle"), text)
|
||||
# Not a choice to offer where it is the only mechanism there is.
|
||||
self.assertTrue(window.evdev_enabled.isHidden())
|
||||
self.assertFalse([button for button in
|
||||
@@ -458,7 +488,7 @@ class MacSettings(Settings):
|
||||
text = self.shortcut_tab_text(window)
|
||||
self.assertIn("Dikte asks macOS for these combinations", text)
|
||||
self.assertNotIn("KWin", text)
|
||||
self.assertNotIn("__main__.py toggle", text)
|
||||
self.assertNotIn(ipc.command_for("toggle"), text)
|
||||
|
||||
def test_the_paste_keys_on_offer_are_the_ones_a_mac_uses(self):
|
||||
window = self.window(cfg.Config())
|
||||
@@ -482,7 +512,7 @@ class KdeSettings(Settings):
|
||||
self.assertIn("KWin only reads shortcut settings at startup", text)
|
||||
self.assertIn("Install as a KDE shortcut", text)
|
||||
self.assertNotIn("keeps no shortcut registry", text)
|
||||
self.assertNotIn("__main__.py toggle", text)
|
||||
self.assertNotIn(ipc.command_for("toggle"), text)
|
||||
# Here it is a choice: the wait for the next login, or the key press
|
||||
# reaching the focused application as well.
|
||||
self.assertFalse(window.evdev_enabled.isHidden())
|
||||
@@ -925,6 +955,36 @@ class Overlay(DikteTest):
|
||||
self.assertFalse(widget.muted)
|
||||
|
||||
|
||||
class MeetingSources(DikteTest):
|
||||
"""What the Meeting tab says about the far side, per sound system.
|
||||
|
||||
The box that picks it is empty on a system that cannot record it, and an
|
||||
empty box with nothing next to it reads as a list that has not loaded yet.
|
||||
"""
|
||||
|
||||
def notes(self, meetings):
|
||||
with mock.patch.object(audio, "sound",
|
||||
return_value=audio.PULSE._replace(
|
||||
meetings=meetings)), \
|
||||
only_these_tools(), \
|
||||
mock.patch.object(settings_ui.SettingsWindow, "_load_models"), \
|
||||
mock.patch.object(settings_ui.SettingsWindow,
|
||||
"_load_transcribe_models"):
|
||||
window = settings_ui.SettingsWindow(cfg.Config())
|
||||
self.addCleanup(window.deleteLater)
|
||||
self.addCleanup(window.close)
|
||||
return " ".join(label.text()
|
||||
for label in window.findChildren(settings_ui.QLabel))
|
||||
|
||||
def test_a_system_that_cannot_record_the_far_side_says_so(self):
|
||||
self.assertIn("nothing that records what the speakers",
|
||||
self.notes(meetings=False))
|
||||
|
||||
def test_a_system_that_can_says_nothing_of_the_sort(self):
|
||||
self.assertNotIn("nothing that records what the speakers",
|
||||
self.notes(meetings=True))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -932,6 +992,13 @@ if __name__ == "__main__":
|
||||
class LocalModels(DikteTest):
|
||||
"""The download boxes, without a network and without either program."""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
# A machine Dikte is actually installed on would otherwise answer the
|
||||
# "nothing can transcribe" question from its real binary and model.
|
||||
self.patch_attr(ggml, "BIN_DIR", self.path("bin"))
|
||||
self.patch_attr(ggml, "MODELS_DIR", self.path("models"))
|
||||
|
||||
def window(self, conf):
|
||||
window = settings_ui.SettingsWindow(conf)
|
||||
self.addCleanup(window.deleteLater)
|
||||
|
||||
Reference in New Issue
Block a user