Exemple #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()
Exemple #2
0
def test_available(mock_sock):
    intf = Systemd()
    intf.available()
Exemple #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()
Exemple #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()
Exemple #5
0
def test_available_undefined():
    intf = Systemd()
    with pytest.raises(RuntimeError):
        intf.available()