How to use suspend_server method in tempest

Best Python code snippet using tempest_python

test_suspend_server.py

Source:test_suspend_server.py Github

copy

Full Screen

1# Copyright 2013 IBM Corp.2#3# Licensed under the Apache License, Version 2.0 (the "License"); you may4# not use this file except in compliance with the License. You may obtain5# a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the12# License for the specific language governing permissions and limitations13# under the License.14from patron.api.openstack.compute.contrib import admin_actions as \15 suspend_server_v216from patron.api.openstack.compute.plugins.v3 import suspend_server as \17 suspend_server_v2118from patron import exception19from patron import test20from patron.tests.unit.api.openstack.compute import admin_only_action_common21from patron.tests.unit.api.openstack import fakes22class SuspendServerTestsV21(admin_only_action_common.CommonTests):23 suspend_server = suspend_server_v2124 controller_name = 'SuspendServerController'25 _api_version = '2.1'26 def setUp(self):27 super(SuspendServerTestsV21, self).setUp()28 self.controller = getattr(self.suspend_server, self.controller_name)()29 self.compute_api = self.controller.compute_api30 def _fake_controller(*args, **kwargs):31 return self.controller32 self.stubs.Set(self.suspend_server, self.controller_name,33 _fake_controller)34 self.mox.StubOutWithMock(self.compute_api, 'get')35 def test_suspend_resume(self):36 self._test_actions(['_suspend', '_resume'])37 def test_suspend_resume_with_non_existed_instance(self):38 self._test_actions_with_non_existed_instance(['_suspend', '_resume'])39 def test_suspend_resume_raise_conflict_on_invalid_state(self):40 self._test_actions_raise_conflict_on_invalid_state(['_suspend',41 '_resume'])42 def test_actions_with_locked_instance(self):43 self._test_actions_with_locked_instance(['_suspend', '_resume'])44class SuspendServerTestsV2(SuspendServerTestsV21):45 suspend_server = suspend_server_v246 controller_name = 'AdminActionsController'47 _api_version = '2'48class SuspendServerPolicyEnforcementV21(test.NoDBTestCase):49 def setUp(self):50 super(SuspendServerPolicyEnforcementV21, self).setUp()51 self.controller = suspend_server_v21.SuspendServerController()52 self.req = fakes.HTTPRequest.blank('')53 def test_suspend_policy_failed(self):54 rule_name = "os_compute_api:os-suspend-server:suspend"55 self.policy.set_rules({rule_name: "project:non_fake"})56 exc = self.assertRaises(57 exception.PolicyNotAuthorized,58 self.controller._suspend, self.req, fakes.FAKE_UUID,59 body={'suspend': {}})60 self.assertEqual(61 "Policy doesn't allow %s to be performed." % rule_name,62 exc.format_message())63 def test_resume_policy_failed(self):64 rule_name = "os_compute_api:os-suspend-server:resume"65 self.policy.set_rules({rule_name: "project:non_fake"})66 exc = self.assertRaises(67 exception.PolicyNotAuthorized,68 self.controller._resume, self.req, fakes.FAKE_UUID,69 body={'resume': {}})70 self.assertEqual(71 "Policy doesn't allow %s to be performed." % rule_name,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful