Exemple #1
0
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'
Exemple #2
0
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] == [
        '&lt;b&gt;title&lt;/b&gt; \\\\ \\u0027 \\u0022',
        '&lt;b&gt;message&lt;/b&gt; \\\\ \\u0027 \\u0022',
    ]
Exemple #3
0
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)