Beispiel #1
0
def test_string_pattern_called(isfile, Popen, systemd_notify):
    '''
    '''
    process_mock = mock.Mock()
    attrs = {'communicate.return_value': (b'output', b'error')}
    process_mock.configure_mock(**attrs)
    Popen.return_value = process_mock
    fs = InsightsFile({
        'file': '',
        'pattern': [],
        'symbolic_name': ''
    }, ['test'], '/')
    fs.get_output()
    Popen.assert_any_call(['grep', '-F', '-v', '-f', ANY],
                          stdin=ANY,
                          stdout=ANY)
Beispiel #2
0
def test_systemd_notify_called_file(Popen, systemd_notify):
    '''
    Systemd_notify is called before a command is run or
    a file is collected
    '''
    process_mock = mock.Mock()
    attrs = {'communicate.return_value': (b'output', b'error')}
    process_mock.configure_mock(**attrs)
    Popen.return_value = process_mock
    fs = InsightsFile({
        'file': '',
        'pattern': [],
        'symbolic_name': ''
    },
                      None,
                      '/',
                      parent_pid='420')
    fs.get_output()
    systemd_notify.assert_called_with('420')