def test_dbus_notifier_replaces_id(): dbus_notifier = notifier.DbusNotifier() with MOCK_DBUS as check_output: dbus_notifier.send(NOTIFICATION) assert check_output.call_args[0][0][10] == '0' dbus_notifier.send(NOTIFICATION) assert check_output.call_args[0][0][10] == '7'
def test_dbus_notifier_escaping(): evil_notification = notifier.Notification('<b>title</b> \\ \' "', None, '<b>message</b> \\ \' "') with MOCK_DBUS as check_output: notifier.DbusNotifier().send(evil_notification) assert check_output.call_args[0][0][12:14] == [ '<b>title</b> \\\\ \\u0027 \\u0022', '<b>message</b> \\\\ \\u0027 \\u0022', ]
def test_dbus_notifier(): with MOCK_DBUS as check_output: notifier.DbusNotifier().send(NOTIFICATION) check_output.assert_called_once_with([ 'gdbus', 'call', '--session', '--dest', 'org.freedesktop.Notifications', '--object-path', '/org/freedesktop/Notifications', '--method', 'org.freedesktop.Notifications.Notify', 'hangups', '0', '', 'John Cleese', 'How about a little red Leicester?', '[]', '{}', ' -1' ], stderr=subprocess.STDOUT)