From cbde088296dee268d2d82ddad41bb10df0a1a1e6 Mon Sep 17 00:00:00 2001 From: tligui_y Date: Sun, 17 Aug 2025 14:06:57 +0200 Subject: [PATCH] Update tests/test_utils_dbusnotify.py --- tests/test_utils_dbusnotify.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/test_utils_dbusnotify.py b/tests/test_utils_dbusnotify.py index 99d19d228..2ee3d13ee 100644 --- a/tests/test_utils_dbusnotify.py +++ b/tests/test_utils_dbusnotify.py @@ -15,23 +15,32 @@ if 'DBUS_SESSION_BUS_ADDRESS' not in os.environ: import dbus +from dbusmock import DBusTestCase, MOCK_IFACE + class _DBusEnv(DBusTestCase): pass @pytest.fixture(scope="session", autouse=True) def _dbus_session_notifications(): - # Lance un bus de session et exporte DBUS_SESSION_BUS_ADDRESS + # 1) lancer un bus de session _DBusEnv.start_session_bus() - p_mock, obj = _DBusEnv.spawn_server( + # 2) démarrer le service Notifications (ARGUMENTS POSITIONNELS) + p_mock = _DBusEnv.spawn_server( 'org.freedesktop.Notifications', '/org/freedesktop/Notifications', 'org.freedesktop.Notifications', - False, # system_bus - None # stdout + False, # system_bus + None # stdout ) + # 3) récupérer l'objet via le bus + bus = _DBusEnv.get_dbus(False) # False => session bus + obj = bus.get_object('org.freedesktop.Notifications', + '/org/freedesktop/Notifications') mock = dbus.Interface(obj, MOCK_IFACE) + + # 4) définir les méthodes minimales mock.AddMethod('org.freedesktop.Notifications', 'GetServerInformation', '', 'ssss', ['pytest-notify', 'pytest-vendor', '1.0', '1.2']) mock.AddMethod('org.freedesktop.Notifications', 'GetCapabilities', @@ -42,7 +51,9 @@ def _dbus_session_notifications(): 'u', '', []) yield - + # Pas de teardown nécessaire ici + + @pytest.fixture def notifier(): """Création de l'objet DBusNotify pour les tests."""