Ejemplo n.º 1
0
def test_systemd_notify_failure_rhel_6(exists, Popen):
    '''
    Test calling systemd-notify on RHEL 6
    On RHEL 6, exists(/usr/bin/systemd-notify) == False
    '''
    exists.return_value = False
    util.systemd_notify('420')
    Popen.assert_not_called()
Ejemplo n.º 2
0
def test_systemd_notify(exists, Popen):
    '''
    Test calling systemd-notify with a "valid" PID
    On RHEL 7, exists(/usr/bin/systemd-notify) == True
    '''
    exists.return_value = True
    Popen.return_value.communicate.return_value = ('', '')
    util.systemd_notify('420')
    Popen.assert_called_once()
Ejemplo n.º 3
0
def test_systemd_notify_failure_bad_pid(exists, Popen):
    '''
    Test calling systemd-notify with an invalid PID
    On RHEL 7, exists(/usr/bin/systemd-notify) == True
    '''
    exists.return_value = True
    util.systemd_notify(None)
    exists.assert_not_called()
    Popen.assert_not_called()
Ejemplo n.º 4
0
def test_systemd_notify_no_socket(exists, Popen):
    '''
    Test this function when NOTIFY_SOCKET is
    undefined, i.e. when we run the client on demand
    and not via systemd job
    '''
    exists.return_value = True
    Popen.return_value.communicate.return_value = ('', '')
    util.systemd_notify('420')
    Popen.assert_not_called()