Here are the examples of the python api mock.call.debug taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
8 Examples
3
Example 1
Project: n6sdk Source File: test_pyramid_commons.py
@patch('n6sdk.pyramid_commons.LOGGER')
def test__exc_to_http_exc__HTTPException_no_server_error(self, LOGGER):
exc = HTTPNotFound()
http_exc = ConfigHelper.exc_to_http_exc(exc)
self.assertIs(http_exc, exc)
self.assertEqual(http_exc.code, 404)
self.assertEqual(LOGGER.mock_calls, [
call.debug(ANY, exc, ANY, 404),
])
3
Example 2
Project: n6sdk Source File: test_pyramid_commons.py
@patch('n6sdk.pyramid_commons.LOGGER')
def test__exc_to_http_exc__AuthorizationError(self, LOGGER):
exc = AuthorizationError(public_message='FOO') # custom public message
http_exc = ConfigHelper.exc_to_http_exc(exc)
self.assertIsInstance(http_exc, HTTPForbidden)
self.assertEqual(http_exc.code, 403)
self.assertEqual(http_exc.detail, 'FOO') # detail == custom public message
self.assertEqual(LOGGER.mock_calls, [
call.debug(ANY, exc, ANY),
])
3
Example 3
Project: n6sdk Source File: test_pyramid_commons.py
@patch('n6sdk.pyramid_commons.LOGGER')
def test__exc_to_http_exc__AuthorizationError_2(self, LOGGER):
exc = AuthorizationError() # no specific public message
http_exc = ConfigHelper.exc_to_http_exc(exc)
self.assertIsInstance(http_exc, HTTPForbidden)
self.assertEqual(http_exc.code, 403)
self.assertEqual(http_exc.detail, # detail == default public message
AuthorizationError.default_public_message)
self.assertEqual(LOGGER.mock_calls, [
call.debug(ANY, exc, ANY),
])
3
Example 4
Project: n6sdk Source File: test_pyramid_commons.py
@patch('n6sdk.pyramid_commons.LOGGER')
def test__exc_to_http_exc__TooMuchDataError(self, LOGGER):
exc = TooMuchDataError(public_message='FOO') # custom public message
http_exc = ConfigHelper.exc_to_http_exc(exc)
self.assertIsInstance(http_exc, HTTPForbidden)
self.assertEqual(http_exc.code, 403)
self.assertEqual(http_exc.detail, 'FOO') # detail == custom public message
self.assertEqual(LOGGER.mock_calls, [
call.debug(ANY, exc, ANY),
])
3
Example 5
Project: n6sdk Source File: test_pyramid_commons.py
@patch('n6sdk.pyramid_commons.LOGGER')
def test__exc_to_http_exc__TooMuchDataError_2(self, LOGGER):
exc = TooMuchDataError() # no specific public message
http_exc = ConfigHelper.exc_to_http_exc(exc)
self.assertIsInstance(http_exc, HTTPForbidden)
self.assertEqual(http_exc.code, 403)
self.assertEqual(http_exc.detail, # detail == default public message
TooMuchDataError.default_public_message)
self.assertEqual(LOGGER.mock_calls, [
call.debug(ANY, exc, ANY),
])
3
Example 6
Project: n6sdk Source File: test_pyramid_commons.py
@patch('n6sdk.pyramid_commons.LOGGER')
def test__exc_to_http_exc__ParamCleaningError(self, LOGGER):
exc = ParamCleaningError(public_message='FOO') # custom public message
http_exc = ConfigHelper.exc_to_http_exc(exc)
self.assertIsInstance(http_exc, HTTPBadRequest)
self.assertEqual(http_exc.code, 400)
self.assertEqual(http_exc.detail, 'FOO') # detail == custom public message
self.assertEqual(LOGGER.mock_calls, [
call.debug(ANY, exc, ANY),
])
3
Example 7
Project: n6sdk Source File: test_pyramid_commons.py
@patch('n6sdk.pyramid_commons.LOGGER')
def test__exc_to_http_exc__ParamCleaningError_2(self, LOGGER):
exc = ParamCleaningError() # no specific public message
http_exc = ConfigHelper.exc_to_http_exc(exc)
self.assertIsInstance(http_exc, HTTPBadRequest)
self.assertEqual(http_exc.code, 400)
self.assertEqual(http_exc.detail, # detail == default public message
ParamCleaningError.default_public_message)
self.assertEqual(LOGGER.mock_calls, [
call.debug(ANY, exc, ANY),
])
0
Example 8
Project: fuel-devops Source File: test_subprocess_runner.py
def test_call_verbose(self, popen, fcntl, select, logger):
popen_obj, _ = self.prepare_close(popen)
select.return_value = [popen_obj.stdout, popen_obj.stderr], [], []
runner = subprocess_runner.Subprocess()
# noinspection PyTypeChecker
result = runner.execute(command, verbose=True)
logger.assert_has_calls((
mock.call.debug(
"Executing command: {!r}".format(command.rstrip())),
mock.call.debug(
'{cmd!r} execution results:\n'
'Exit code: {code!s}\n'
'STDOUT:\n'
'{stdout}\n'
'STDERR:\n'
'{stderr}'.format(
cmd=command,
code=result.exit_code,
stdout=result.stdout_str,
stderr=result.stderr_str
)),
))