Files
aza/AzA march 2026/_test_chat_only_host_update.py

106 lines
3.8 KiB
Python
Raw Normal View History

2026-06-13 22:47:31 +02:00
# -*- coding: utf-8 -*-
"""Tests: Chat-only Host, gemeinsame Core-Mixins, Update-Badge."""
from __future__ import annotations
import inspect
import os
import unittest
class TestSharedCoreArchitecture(unittest.TestCase):
def test_basis14_uses_shared_mixins(self):
import basis14
src = inspect.getsource(basis14.KGDesktopApp)
self.assertIn("EmpfangDesktopCoreMixin", src)
self.assertIn("EmpfangHostPollMixin", src)
def test_core_has_singleton_open(self):
import aza_empfang_desktop_core as core
self.assertIn("_empfang_open_webview_singleton", inspect.getsource(core.EmpfangDesktopCoreMixin))
self.assertIn("_maybe_autostart_kontakt_panel", inspect.getsource(core.EmpfangDesktopCoreMixin))
def test_poll_mixin_shared(self):
import aza_empfang_host_poll as poll
self.assertIn("_empfang_background_poll", inspect.getsource(poll.EmpfangHostPollMixin))
self.assertIn("show_incoming_message_popup", inspect.getsource(poll.EmpfangHostPollMixin))
class TestChatHostModule(unittest.TestCase):
def test_chat_host_exports(self):
import aza_chat_desktop_host as ch
self.assertTrue(hasattr(ch, "ChatDesktopHost"))
self.assertTrue(callable(ch.try_acquire_chat_host_singleton))
def test_chat_host_hidden_and_poll(self):
src = inspect.getsource(__import__("aza_chat_desktop_host").ChatDesktopHost)
self.assertIn("withdraw", src)
self.assertIn("_empfang_background_poll", src)
self.assertIn("empfang_popup_host", src)
def test_office_running_skips_poll_at_init(self):
src = inspect.getsource(__import__("aza_chat_desktop_host").ChatDesktopHost.__init__)
self.assertIn("_office_desktop_running", src)
def test_chat_app_entry(self):
import aza_chat_app
self.assertTrue(callable(aza_chat_app.main))
class TestChatUpdateChannel(unittest.TestCase):
def test_chat_manifest_urls_defined(self):
from desktop_update_check import CHAT_UPDATE_MANIFEST_URLS, sync_chat_update_hint, read_chat_update_hint
self.assertTrue(len(CHAT_UPDATE_MANIFEST_URLS) >= 1)
sync_chat_update_hint(None)
self.assertIsNone(read_chat_update_hint())
def test_optional_update_no_startup_dialog(self):
from desktop_update_check import _startup_should_show_dialog
info = {"update_level": "recommended", "below_min_required": False}
self.assertFalse(_startup_should_show_dialog(info))
def test_chat_hint_roundtrip(self):
from desktop_update_check import sync_chat_update_hint, read_chat_update_hint
sync_chat_update_hint({"update_available": True, "latest_version": "9.9.9", "update_level": "recommended"})
hint = read_chat_update_hint()
self.assertTrue(hint and hint.get("available"))
sync_chat_update_hint(None)
def test_kontakt_badge_api(self):
import aza_empfang_webview as ew
src = inspect.getsource(ew.EmpfangWebviewApi)
self.assertIn("get_chat_update_hint", src)
self.assertIn("_inject_kontakt_update_badge", src)
self.assertIn("request_chat_update_dialog", src)
def test_no_aktuell_in_badge_injection(self):
import aza_empfang_webview as ew
src = inspect.getsource(ew.EmpfangWebviewApi._inject_kontakt_update_badge)
self.assertNotIn("Aktuell", src)
class TestInstallerPrep(unittest.TestCase):
def test_installer_has_chatonly_type(self):
iss = open(
os.path.join(os.path.dirname(__file__), "installer", "aza_installer.iss"),
encoding="utf-8",
).read()
self.assertIn("chatonly", iss)
self.assertIn("Nur AzA PraxisChat", iss)
def test_aza_chat_spec_exists(self):
self.assertTrue(os.path.isfile(os.path.join(os.path.dirname(__file__), "AZA_Chat.spec")))
if __name__ == "__main__":
unittest.main()