Best Python code snippet using tempest_python
test_trunk.py
Source:test_trunk.py
...56 return self.client.show_trunk(trunk_id)57 def _list_trunks(self):58 return self.client.list_trunks()59class TrunkTestJSON(TrunkTestJSONBase):60 def _test_create_trunk(self, subports):61 trunk = self._create_trunk_with_network_and_parent(subports)62 observed_trunk = self._show_trunk(trunk['trunk']['id'])63 self.assertEqual(trunk, observed_trunk)64 @test.idempotent_id('e1a6355c-4768-41f3-9bf8-0f1d192bd501')65 def test_create_trunk_empty_subports_list(self):66 self._test_create_trunk([])67 @test.idempotent_id('382dfa39-ca03-4bd3-9a1c-91e36d2e3796')68 def test_create_trunk_subports_not_specified(self):69 self._test_create_trunk(None)70 @test.idempotent_id('7de46c22-e2b6-4959-ac5a-0e624632ab32')71 def test_create_show_delete_trunk(self):72 trunk = self._create_trunk_with_network_and_parent(None)73 trunk_id = trunk['trunk']['id']74 parent_port_id = trunk['trunk']['port_id']75 res = self._show_trunk(trunk_id)76 self.assertEqual(trunk_id, res['trunk']['id'])77 self.assertEqual(parent_port_id, res['trunk']['port_id'])78 self.client.delete_trunk(trunk_id)79 self.assertRaises(lib_exc.NotFound, self._show_trunk, trunk_id)80 @test.idempotent_id('8d83a6ca-662d-45b8-8062-d513077296aa')81 @test.requires_ext(extension="project-id", service="network")82 def test_show_trunk_has_project_id(self):83 trunk = self._create_trunk_with_network_and_parent(None)...
test_trunks_client.py
Source:test_trunks_client.py
...64 super(TestTrunksClient, self).setUp()65 fake_auth = fake_auth_provider.FakeAuthProvider()66 self.trunks_client = trunks_client.TrunksClient(67 fake_auth, "network", "regionOne")68 def _test_create_trunk(self, bytes_body=False):69 self.check_service_client_function(70 self.trunks_client.create_trunk,71 "tempest.lib.common.rest_client.RestClient.post",72 {"trunk": self.FAKE_TRUNKS["trunks"][0]},73 bytes_body,74 201,75 **self.FAKE_TRUNK_1)76 def _test_list_trunks(self, bytes_body=False):77 self.check_service_client_function(78 self.trunks_client.list_trunks,79 "tempest.lib.common.rest_client.RestClient.get",80 self.FAKE_TRUNKS,81 bytes_body,82 200)83 def _test_show_trunk(self, bytes_body=False):84 self.check_service_client_function(85 self.trunks_client.show_trunk,86 "tempest.lib.common.rest_client.RestClient.get",87 {"trunk": self.FAKE_TRUNKS["trunks"][0]},88 bytes_body,89 200,90 trunk_id=self.FAKE_TRUNK_ID)91 def _test_update_trunk(self, bytes_body=False):92 update_kwargs = {93 "admin_state_up": True,94 "name": "new_trunk"95 }96 resp_body = {97 "trunk": copy.deepcopy(98 self.FAKE_TRUNKS["trunks"][0]99 )100 }101 resp_body["trunk"].update(update_kwargs)102 self.check_service_client_function(103 self.trunks_client.update_trunk,104 "tempest.lib.common.rest_client.RestClient.put",105 resp_body,106 bytes_body,107 200,108 trunk_id=self.FAKE_TRUNK_ID,109 **update_kwargs)110 def _test_add_subports_to_trunk(self, bytes_body=False):111 sub_ports = [{112 "port_id": "f04eb36-6c84-11eb-b0ab-4fc62961629d",113 "segmentation_type": "vlan",114 "segmentation_id": "1001"115 }]116 resp_body = copy.deepcopy(self.FAKE_TRUNKS["trunks"][0])117 resp_body["sub_ports"].append(sub_ports)118 self.check_service_client_function(119 self.trunks_client.add_subports_to_trunk,120 "tempest.lib.common.rest_client.RestClient.put",121 resp_body,122 bytes_body,123 200,124 trunk_id=self.FAKE_TRUNK_ID,125 sub_ports=sub_ports)126 def _test_delete_subports_from_trunk(self, bytes_body=False):127 fake_sub_ports = self.FAKE_TRUNKS['trunks'][0]['sub_ports']128 sub_ports = [129 {"port_id": fake_sub_ports[0]['port_id']}130 ]131 resp_body = copy.deepcopy(self.FAKE_TRUNKS["trunks"][0])132 resp_body['sub_ports'] = []133 self.check_service_client_function(134 self.trunks_client.delete_subports_from_trunk,135 "tempest.lib.common.rest_client.RestClient.put",136 resp_body,137 bytes_body,138 200,139 trunk_id=self.FAKE_TRUNK_ID,140 sub_ports=sub_ports)141 def test_create_trunk_with_str_body(self):142 self._test_create_trunk()143 def test_create_trunk_with_bytes_body(self):144 self._test_create_trunk(bytes_body=True)145 def test_list_trunks_with_str_body(self):146 self._test_list_trunks()147 def test_list_trunks_with_bytes_body(self):148 self._test_list_trunks(bytes_body=True)149 def test_show_trunk_with_str_body(self):150 self._test_show_trunk()151 def test_show_trunk_with_bytes_body(self):152 self._test_show_trunk(bytes_body=True)153 def test_update_trunk_with_str_body(self):154 self._test_update_trunk()155 def test_update_trunk_with_bytes_body(self):156 self._test_update_trunk(bytes_body=True)157 def test_add_subports_to_trunk_str_body(self):158 self._test_add_subports_to_trunk()...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!