-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
I had originally opened #230, but then due to health issues I spent a few months without ever answering @martinpitt in that issue. 😞
So now I did manage to to get a machine id in my CI. 😉
Now what I need is to mock org.freedesktop.Notifications so the tests can send notifications while there is a dbus session service running to catch those.
I think I can do that as follows:
import dbus
import dbusmock
import subprocess
class TestMyProgram(dbusmock.DBusTestCase):
@classmethod
def setUpClass(cls):
cls.start_session_bus()
cls.dbus_con = cls.get_dbus(session_bus=True)
def setUp(self):
self.p_mock = self.spawn_server('org.freedesktop.Notification',
'/org/freedesktop/Notification',
'org.freedesktop.Notification',
session_bus=True,
stdout=subprocess.PIPE)
# Get a proxy for the UPower object's Mock interface
self.dbus_notification_mock = dbus.Interface(self.dbus_con.get_object(
'org.freedesktop.Notification', '/org/freedesktop/Notification'),
dbusmock.MOCK_IFACE)
self.dbus_upower_mock.AddMethod('', 'Notify', '', '', '')
def tearDown(self):
self.p_mock.stdout.close()
self.p_mock.terminate()
self.p_mock.wait()
def test_suspend_on_idle(self):
# That's where I suppose I can run the tests which would send notifications, right? 🤔
# now check the log that we got one Suspend() call
self.assertRegex(self.p_mock.stdout.readline(), b'^[0-9.]+ Suspend$')
Again, my apologies for not having given any sign of life, I'll try harder next time, I promise. 🙇
Metadata
Metadata
Assignees
Labels
No labels