Beispiel #1
0
def test_known_available(tmpdir):
    addr = tmpdir.join('known')
    s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM | socket.SOCK_CLOEXEC)
    s.bind(str(addr))
    try:
        intf = Systemd(str(addr))
        intf.available()
    finally:
        s.close()
Beispiel #2
0
def test_available(mock_sock):
    intf = Systemd()
    intf.available()
Beispiel #3
0
def test_available_ioerror(tmpdir):
    with mock.patch.dict('os.environ'):
        os.environ['NOTIFY_SOCKET'] = str(tmpdir.join('FOO'))
        intf = Systemd()
        with pytest.raises(RuntimeError):
            intf.available()
Beispiel #4
0
def test_available_invalid():
    with mock.patch.dict('os.environ'):
        os.environ['NOTIFY_SOCKET'] = 'FOO'
        intf = Systemd()
        with pytest.raises(RuntimeError):
            intf.available()
Beispiel #5
0
def test_available_undefined():
    intf = Systemd()
    with pytest.raises(RuntimeError):
        intf.available()