示例#1
0
def test_notify_call__dbus_notify(monkeypatch):
    dbus_notify_args = [None, None, None]

    def fake_dbus_notify(title, message, duration):
        dbus_notify_args[0] = title
        dbus_notify_args[1] = message
        dbus_notify_args[2] = duration
    monkeypatch.setattr('sys.platform', 'linux')
    monkeypatch.setattr('gridsync.desktop._dbus_notify', fake_dbus_notify)
    notify(None, 'test_title', 'test_message', 9001)
    assert dbus_notify_args == ['test_title', 'test_message', 9001]
示例#2
0
def test_notify_call_systray_show_message(monkeypatch):
    show_message_args = [None, None, None]

    def fake_show_message(title, message, msecs):
        show_message_args[0] = title
        show_message_args[1] = message
        show_message_args[2] = msecs
    fake_systray = MagicMock()
    fake_systray.showMessage = fake_show_message
    monkeypatch.setattr('sys.platform', 'NOT_linux')
    notify(fake_systray, 'test_title', 'test_message', 9001)
    assert show_message_args == ['test_title', 'test_message', 9001]
示例#3
0
def test_notify_call__dbus_notify(monkeypatch):
    dbus_notify_args = [None, None, None]

    def fake_dbus_notify(title, message, duration):
        dbus_notify_args[0] = title
        dbus_notify_args[1] = message
        dbus_notify_args[2] = duration

    monkeypatch.setattr("sys.platform", "linux")
    monkeypatch.setattr("gridsync.desktop._dbus_notify", fake_dbus_notify)
    notify(None, "test_title", "test_message", 9001)
    assert dbus_notify_args == ["test_title", "test_message", 9001]
示例#4
0
def test_notify_call__dbus_notify_fallback_on_error(error, monkeypatch):
    show_message_args = [None, None, None]

    def fake_show_message(title, message, msecs):
        show_message_args[0] = title
        show_message_args[1] = message
        show_message_args[2] = msecs
    fake_systray = MagicMock()
    fake_systray.showMessage = fake_show_message
    monkeypatch.setattr('sys.platform', 'linux')
    monkeypatch.setattr(
        'gridsync.desktop._dbus_notify', MagicMock(side_effect=error))
    notify(fake_systray, 'test_title', 'test_message', 9001)
    assert show_message_args == ['test_title', 'test_message', 9001]
示例#5
0
 def show_message(self, title, message, duration=5000):
     notify(self.systray, title, message, duration)