Esempio n. 1
0
def test_connection_subprocess(instance):
    check = IbmICheck('ibm_i', {}, [instance])
    check.load_configuration_models()
    with mock.patch(
            'datadog_checks.ibm_i.IbmICheck._create_connection_subprocess'
    ) as m:
        check.connection_subprocess
        check._subprocess = mock.MagicMock()
        check.connection_subprocess
    m.assert_called_once()
Esempio n. 2
0
def test_execute_query(instance):
    """Check that execute_query reads and parses the process stdout."""
    check = IbmICheck('ibm_i', {}, [instance])
    check.load_configuration_models()
    check._subprocess = mock.MagicMock()
    check._subprocess.stdout = mock.MagicMock()
    check._subprocess.stdout.readline = mock.MagicMock(
        return_value='{"a": "b"}')
    assert next(check.execute_query({
        'text': 'query',
        'timeout': 2
    })) == {
        'a': 'b'
    }