Ejemplo n.º 1
0
def test__dbus_notify_interface_error(monkeypatch):
    monkeypatch.setattr(
        "PyQt5.QtDBus.QDBusConnection.isConnected", lambda _: True
    )
    monkeypatch.setattr("PyQt5.QtDBus.QDBusError.type", lambda _: 9999)
    with pytest.raises(RuntimeError):
        _dbus_notify("", "")
Ejemplo n.º 2
0
def test__dbus_notify_interface_called(monkeypatch):
    was_called = [False]

    def fake_call(*_):
        was_called[0] = True
    monkeypatch.setattr(
        'PyQt5.QtDBus.QDBusConnection.isConnected', lambda _: True)
    monkeypatch.setattr('PyQt5.QtDBus.QDBusError.type', lambda _: 0)
    monkeypatch.setattr('PyQt5.QtDBus.QDBusInterface.call', fake_call)
    _dbus_notify('', '')
    assert was_called[0] is True
Ejemplo n.º 3
0
def test__dbus_notify_bus_not_connected(monkeypatch):
    monkeypatch.setattr(
        'PyQt5.QtDBus.QDBusConnection.isConnected', lambda _: False)
    with pytest.raises(OSError):
        _dbus_notify('', '')