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:
Riccardo Pittau 2022-12-06 17:22:42 +01:00
parent c52873796f
commit 24d88f4aec
1 changed files with 6 additions and 5 deletions

View File

@ -543,10 +543,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,
@ -555,12 +555,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):