How to use _test_update_subnet method in tempest

Best Python code snippet using tempest_python

test_subnet_service_types.py

Source:test_subnet_service_types.py Github

copy

Full Screen

...86 res = self._create_service_subnet()87 subnet = self.deserialize('json', res)88 subnet = subnet['subnet']89 self.assertFalse(subnet['service_types'])90 def _test_update_subnet(self, subnet, service_types, fail_code=None):91 data = {'subnet': {'service_types': service_types}}92 req = self.new_update_request('subnets', data, subnet['id'])93 res = self.deserialize(self.fmt, req.get_response(self.api))94 if fail_code is not None:95 self.assertEqual(fail_code,96 res['NeutronError']['type'])97 else:98 subnet = res['subnet']99 self.assertEqual(len(service_types),100 len(subnet['service_types']))101 for service in service_types:102 self.assertIn(service, subnet['service_types'])103 def test_update_subnet_zero_to_one(self):104 service_types = ['network:foo']105 # Create a subnet with no service type106 res = self._create_service_subnet()107 subnet = self.deserialize('json', res)['subnet']108 # Update it with a single service type109 self._test_update_subnet(subnet, service_types)110 def test_update_subnet_one_to_two(self):111 service_types = ['network:foo']112 # Create a subnet with one service type113 res = self._create_service_subnet(service_types)114 subnet = self.deserialize('json', res)['subnet']115 # Update it with two service types116 service_types.append('compute:bar')117 self._test_update_subnet(subnet, service_types)118 def test_update_subnet_two_to_one(self):119 service_types = ['network:foo', 'compute:bar']120 # Create a subnet with two service types121 res = self._create_service_subnet(service_types)122 subnet = self.deserialize('json', res)['subnet']123 # Update it with one service type124 service_types = ['network:foo']125 self._test_update_subnet(subnet, service_types)126 def test_update_subnet_one_to_zero(self):127 service_types = ['network:foo']128 # Create a subnet with one service type129 res = self._create_service_subnet(service_types)130 subnet = self.deserialize('json', res)['subnet']131 # Update it with zero service types132 service_types = []133 self._test_update_subnet(subnet, service_types)134 def test_update_subnet_invalid_type(self):135 # Create a subnet with no service type136 res = self._create_service_subnet()137 subnet = self.deserialize('json', res)['subnet']138 # Update it with invalid service type(s)139 self._test_update_subnet(subnet, ['foo'],140 fail_code='InvalidSubnetServiceType')141 self._test_update_subnet(subnet, [2],142 fail_code='InvalidInputSubnetServiceType')143 def _assert_port_res(self, port, service_type, subnet, fallback,144 error='IpAddressGenerationFailureNoMatchingSubnet'):145 res = self.deserialize('json', port)146 if fallback:147 port = res['port']148 self.assertEqual(1, len(port['fixed_ips']))149 self.assertEqual(service_type, port['device_owner'])150 self.assertEqual(subnet['id'], port['fixed_ips'][0]['subnet_id'])151 else:152 self.assertEqual(error, res['NeutronError']['type'])153 def test_create_port_with_matching_service_type(self):154 with self.network() as network:155 pass...

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