diff options
author | Zuul <zuul@review.opendev.org> | 2023-04-20 17:15:33 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2023-04-20 17:15:33 +0000 |
commit | 6b3adacc66194e3ea32970f894798c61e7814f53 (patch) | |
tree | 64d8360334832c09a5c5ef257b31b5bc4db2a516 /nova/tests/functional/api_sample_tests/test_remote_consoles.py | |
parent | 1cf650bf4f25f15ae80c31a67e54ce6615231375 (diff) | |
parent | 71855163a944e437f9c48a5765f683b55a28c720 (diff) | |
download | nova-71574a4f75cedfff364e216ed61f1ed3d3c5403c.tar.gz |
Merge "Handle InstanceInvalidState exception" into stable/zed26.1.1
Diffstat (limited to 'nova/tests/functional/api_sample_tests/test_remote_consoles.py')
-rw-r--r-- | nova/tests/functional/api_sample_tests/test_remote_consoles.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/nova/tests/functional/api_sample_tests/test_remote_consoles.py b/nova/tests/functional/api_sample_tests/test_remote_consoles.py index 986826bfee..e304402ee9 100644 --- a/nova/tests/functional/api_sample_tests/test_remote_consoles.py +++ b/nova/tests/functional/api_sample_tests/test_remote_consoles.py @@ -13,6 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + +from nova.compute import api as compute +from nova import exception from nova.tests.functional.api_sample_tests import test_servers HTTP_RE = r'(https?://)([\w\d:#@%/;$()~_?\+-=\\.&](#!)?)*' @@ -38,6 +42,22 @@ class ConsolesSampleJsonTests(test_servers.ServersSampleBase): self._verify_response('get-vnc-console-post-resp', {'url': HTTP_RE}, response, 200) + @mock.patch.object(compute.API, 'get_vnc_console') + def test_get_vnc_console_instance_invalid_state(self, + mock_get_vnc_console): + uuid = self._post_server() + + def fake_get_vnc_console(*args, **kwargs): + raise exception.InstanceInvalidState( + attr='fake_attr', state='fake_state', method='fake_method', + instance_uuid=uuid) + + mock_get_vnc_console.side_effect = fake_get_vnc_console + response = self._do_post('servers/%s/action' % uuid, + 'get-vnc-console-post-req', + {'action': 'os-getVNCConsole'}) + self.assertEqual(409, response.status_code) + def test_get_spice_console(self): uuid = self._post_server() response = self._do_post('servers/%s/action' % uuid, |