How to use _test_create_flavor method in tempest

Best Python code snippet using tempest_python

test_flavors_client.py

Source:test_flavors_client.py Github

copy

Full Screen

...71 def test_show_flavor_str_body(self):72 self._test_show_flavor(bytes_body=False)73 def test_show_flavor_byte_body(self):74 self._test_show_flavor(bytes_body=True)75 def _test_create_flavor(self, bytes_body=False):76 expected = {"flavor": TestFlavorsClient.FAKE_FLAVOR}77 request = copy.deepcopy(TestFlavorsClient.FAKE_FLAVOR)78 # The 'links' parameter should not be passed in79 del request['links']80 self.check_service_client_function(81 self.client.create_flavor,82 'tempest.common.service_client.ServiceClient.post',83 expected,84 bytes_body,85 **request)86 def test_create_flavor_str_body(self):87 self._test_create_flavor(bytes_body=False)88 def test_create_flavor__byte_body(self):89 self._test_create_flavor(bytes_body=True)90 def test_delete_flavor(self):91 self.check_service_client_function(92 self.client.delete_flavor,93 'tempest.common.service_client.ServiceClient.delete',94 {}, status=202, flavor_id='c782b7a9-33cd-45f0-b795-7f87f456408b')95 def _test_is_resource_deleted(self, flavor_id, is_deleted=True,96 bytes_body=False):97 body = json.dumps({'flavors': [TestFlavorsClient.FAKE_FLAVOR]})98 if bytes_body:99 body = body.encode('utf-8')100 response = (httplib2.Response({'status': 200}), body)101 self.useFixture(mockpatch.Patch(102 'tempest.common.service_client.ServiceClient.get',103 return_value=response))...

Full Screen

Full Screen

test_flavors.py

Source:test_flavors.py Github

copy

Full Screen

...98 except Exception:99 return100 # it should have ended in the except block above101 self.assertTrue(False)102 def _test_create_flavor(self, no_rng=False):103 return_value = {"flavor": {"id": "MyFakeID", "name": "MyID"}}104 self.Service.flavor_list = []105 client = self.CLIENT_MOCK106 mock_function = mock.Mock(return_value=return_value)107 self.useFixture(MonkeyPatch(client + '.create_flavor', mock_function))108 mock_function = mock.Mock(return_value={})109 self.useFixture(MonkeyPatch(client + '.set_flavor_extra_spec',110 mock_function))111 resp = self.Service.create_flavor("MyID", C.DEFAULT_FLAVOR_RAM,112 C.DEFAULT_FLAVOR_VCPUS,113 C.DEFAULT_FLAVOR_DISK,114 no_rng=no_rng)115 self.assertEqual(resp, return_value['flavor']['id'])116 return mock_function117 def test_create_flavor_rng(self):118 mock_function = self._test_create_flavor()119 calls = [mock.call(flavor_id='MyFakeID', **{'hw_rng:allowed': 'True'})]120 mock_function.assert_has_calls(calls, any_order=True)121 def test_create_flavor_no_rng(self):122 self.Service.no_rng = True123 mock_function = self._test_create_flavor(no_rng=True)124 calls = [mock.call(flavor_id='MyFakeID')]125 mock_function.assert_has_calls(calls, any_order=True)126 def test_find_flavor_by_id(self):127 return_value = {"flavors": self.FLAVORS_LIST}128 mock_function = mock.Mock(return_value=return_value)129 self.useFixture(MonkeyPatch(self.CLIENT_MOCK + '.list_flavors',130 mock_function))131 resp = self.Service.find_flavor_by_id("MyFakeID")132 self.assertEqual(resp, "MyFakeID")133 # test no flavor found case134 resp = self.Service.find_flavor_by_id("NotExist")135 self.assertEqual(resp, None)136 def test_find_flavor_by_name(self):137 return_value = {"flavors": self.FLAVORS_LIST}...

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