Merge "Handle proper code_status in unit test"
This commit is contained in:
commit
9427360ccb
@ -579,10 +579,10 @@ class ConnectorOpTestCase(base.TestCase):
|
||||
def test_access_error_basic_auth(self, mock_log):
|
||||
self.conn._auth.can_refresh_session.return_value = False
|
||||
self.conn._session.auth = ('foo', 'bar')
|
||||
self.request.return_value.status_code = http_client.FORBIDDEN
|
||||
self.request.return_value.status_code = 403
|
||||
mock_response = mock.Mock()
|
||||
mock_response.json.side_effect = ValueError('no json')
|
||||
mock_response.status_code = http_client.FORBIDDEN
|
||||
mock_response.status_code = 403
|
||||
self.request.return_value.json.side_effect = ValueError('no json')
|
||||
|
||||
with self.assertRaisesRegex(exceptions.AccessError,
|
||||
@ -591,12 +591,13 @@ class ConnectorOpTestCase(base.TestCase):
|
||||
exc = cm.exception
|
||||
self.assertEqual(http_client.FORBIDDEN, exc.status_code)
|
||||
self.conn._auth.authenticate.assert_not_called()
|
||||
error_msg = (f'HTTP GET http://redfish/v1/SessionService '
|
||||
f'returned code {exc.status_code}. unknown error '
|
||||
f'Extended information: None')
|
||||
mock_log.assert_called_once_with(
|
||||
"We have encountered an AccessError when using 'basic' "
|
||||
"authentication. %(err)s",
|
||||
{'err': 'HTTP GET http://redfish/v1/SessionService '
|
||||
'returned code HTTPStatus.FORBIDDEN. unknown error '
|
||||
'Extended information: None'}
|
||||
{'err': error_msg}
|
||||
)
|
||||
|
||||
def test__op_raises_connection_error(self):
|
||||
|
Loading…
Reference in New Issue
Block a user