Handle proper code_status in unit test
Python 3.11 correctly resolve the code_status with its number. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1025124 for reference. Change-Id: I063f5c3a280262f1a1d70b44906a504e2b16134d
This commit is contained in:
parent
c52873796f
commit
24d88f4aec
@ -543,10 +543,10 @@ class ConnectorOpTestCase(base.TestCase):
|
|||||||
def test_access_error_basic_auth(self, mock_log):
|
def test_access_error_basic_auth(self, mock_log):
|
||||||
self.conn._auth.can_refresh_session.return_value = False
|
self.conn._auth.can_refresh_session.return_value = False
|
||||||
self.conn._session.auth = ('foo', 'bar')
|
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 = mock.Mock()
|
||||||
mock_response.json.side_effect = ValueError('no json')
|
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')
|
self.request.return_value.json.side_effect = ValueError('no json')
|
||||||
|
|
||||||
with self.assertRaisesRegex(exceptions.AccessError,
|
with self.assertRaisesRegex(exceptions.AccessError,
|
||||||
@ -555,12 +555,13 @@ class ConnectorOpTestCase(base.TestCase):
|
|||||||
exc = cm.exception
|
exc = cm.exception
|
||||||
self.assertEqual(http_client.FORBIDDEN, exc.status_code)
|
self.assertEqual(http_client.FORBIDDEN, exc.status_code)
|
||||||
self.conn._auth.authenticate.assert_not_called()
|
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(
|
mock_log.assert_called_once_with(
|
||||||
"We have encountered an AccessError when using 'basic' "
|
"We have encountered an AccessError when using 'basic' "
|
||||||
"authentication. %(err)s",
|
"authentication. %(err)s",
|
||||||
{'err': 'HTTP GET http://redfish/v1/SessionService '
|
{'err': error_msg}
|
||||||
'returned code HTTPStatus.FORBIDDEN. unknown error '
|
|
||||||
'Extended information: None'}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def test__op_raises_connection_error(self):
|
def test__op_raises_connection_error(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user