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()
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' }