Update tests/test_utils_dbusnotify.py
Run CI Tests / test (push) Successful in 1m17s

This commit is contained in:
2025-08-17 14:06:57 +02:00
parent ae5ccfd12e
commit cbde088296
+16 -5
View File
@@ -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."""