Best Python code snippet using tempest_python
test_subnetpools.py
Source: test_subnetpools.py
...101 @test.idempotent_id('741d08c2-1e3f-42be-99c7-0ea93c5b728c')102 def test_get_subnetpool(self):103 created_subnetpool = self._create_subnetpool()104 prefixlen = self._subnetpool_data['min_prefixlen']105 body = self.client.show_subnetpool(created_subnetpool['id'])106 subnetpool = body['subnetpool']107 self.assertEqual(created_subnetpool['name'], subnetpool['name'])108 self.assertEqual(created_subnetpool['id'], subnetpool['id'])109 self.assertEqual(prefixlen, subnetpool['min_prefixlen'])110 self.assertEqual(prefixlen, subnetpool['default_prefixlen'])111 self.assertFalse(subnetpool['shared'])112 @test.idempotent_id('5bf9f1e2-efc8-4195-acf3-d12b2bd68dd3')113 @test.requires_ext(extension="project-id", service="network")114 def test_show_subnetpool_has_project_id(self):115 subnetpool = self._create_subnetpool()116 body = self.client.show_subnetpool(subnetpool['id'])117 show_subnetpool = body['subnetpool']118 self.assertIn('project_id', show_subnetpool)119 self.assertIn('tenant_id', show_subnetpool)120 self.assertEqual(self.client.tenant_id, show_subnetpool['project_id'])121 self.assertEqual(self.client.tenant_id, show_subnetpool['tenant_id'])122 @test.idempotent_id('764f1b93-1c4a-4513-9e7b-6c2fc5e9270c')123 def test_tenant_update_subnetpool(self):124 created_subnetpool = self._create_subnetpool()125 pool_id = created_subnetpool['id']126 subnetpool_data = self._new_subnetpool_attributes()127 self.client.update_subnetpool(created_subnetpool['id'],128 **subnetpool_data)129 body = self.client.show_subnetpool(pool_id)130 subnetpool = body['subnetpool']131 self._check_equality_updated_subnetpool(subnetpool_data,132 subnetpool)133 self.assertFalse(subnetpool['shared'])134 @test.idempotent_id('4b496082-c992-4319-90be-d4a7ce646290')135 def test_update_subnetpool_prefixes_append(self):136 # We can append new prefixes to subnetpool137 create_subnetpool = self._create_subnetpool()138 pool_id = create_subnetpool['id']139 old_prefixes = self._subnetpool_data['prefixes']140 new_prefixes = old_prefixes[:]141 new_prefixes.append(self.new_prefix)142 subnetpool_data = {'prefixes': new_prefixes}143 self.client.update_subnetpool(pool_id, **subnetpool_data)144 body = self.client.show_subnetpool(pool_id)145 prefixes = body['subnetpool']['prefixes']146 self.assertIn(self.new_prefix, prefixes)147 self.assertIn(old_prefixes[0], prefixes)148 @test.idempotent_id('2cae5d6a-9d32-42d8-8067-f13970ae13bb')149 def test_update_subnetpool_prefixes_extend(self):150 # We can extend current subnetpool prefixes151 created_subnetpool = self._create_subnetpool()152 pool_id = created_subnetpool['id']153 old_prefixes = self._subnetpool_data['prefixes']154 subnetpool_data = {'prefixes': [self.larger_prefix]}155 self.client.update_subnetpool(pool_id, **subnetpool_data)156 body = self.client.show_subnetpool(pool_id)157 prefixes = body['subnetpool']['prefixes']158 self.assertIn(self.larger_prefix, prefixes)159 self.assertNotIn(old_prefixes[0], prefixes)160 @test.idempotent_id('d70c6c35-913b-4f24-909f-14cd0d29b2d2')161 def test_admin_create_shared_subnetpool(self):162 created_subnetpool = self._create_subnetpool(is_admin=True,163 shared=True)164 pool_id = created_subnetpool['id']165 # Shared subnetpool can be retrieved by tenant user.166 body = self.client.show_subnetpool(pool_id)167 subnetpool = body['subnetpool']168 self.assertEqual(created_subnetpool['name'], subnetpool['name'])169 self.assertTrue(subnetpool['shared'])170 def _create_subnet_from_pool(self, subnet_values=None, pool_values=None):171 if pool_values is None:172 pool_values = {}173 created_subnetpool = self._create_subnetpool(**pool_values)174 pool_id = created_subnetpool['id']175 subnet_name = data_utils.rand_name(SUBNETPOOL_NAME)176 network = self.create_network()177 subnet_kwargs = {'name': subnet_name,178 'subnetpool_id': pool_id}179 if subnet_values:180 subnet_kwargs.update(subnet_values)181 # not creating the subnet using the base.create_subnet because182 # that function needs to be enhanced to support subnet_create when183 # prefixlen and subnetpool_id is specified.184 body = self.client.create_subnet(185 network_id=network['id'],186 ip_version=self._ip_version,187 **subnet_kwargs)188 subnet = body['subnet']189 return pool_id, subnet190 @test.idempotent_id('1362ed7d-3089-42eb-b3a5-d6cb8398ee77')191 def test_create_subnet_from_pool_with_prefixlen(self):192 subnet_values = {"prefixlen": self.max_prefixlen}193 pool_id, subnet = self._create_subnet_from_pool(194 subnet_values=subnet_values)195 cidr = str(subnet['cidr'])196 self.assertEqual(pool_id, subnet['subnetpool_id'])197 self.assertTrue(cidr.endswith(str(self.max_prefixlen)))198 @test.idempotent_id('86b86189-9789-4582-9c3b-7e2bfe5735ee')199 def test_create_subnet_from_pool_with_subnet_cidr(self):200 subnet_values = {"cidr": self.subnet_cidr}201 pool_id, subnet = self._create_subnet_from_pool(202 subnet_values=subnet_values)203 cidr = str(subnet['cidr'])204 self.assertEqual(pool_id, subnet['subnetpool_id'])205 self.assertEqual(cidr, self.subnet_cidr)206 @test.idempotent_id('83f76e3a-9c40-40c2-a015-b7c5242178d8')207 def test_create_subnet_from_pool_with_default_prefixlen(self):208 # If neither cidr nor prefixlen is specified,209 # subnet will use subnetpool default_prefixlen for cidr.210 pool_id, subnet = self._create_subnet_from_pool()211 cidr = str(subnet['cidr'])212 self.assertEqual(pool_id, subnet['subnetpool_id'])213 prefixlen = self._subnetpool_data['min_prefixlen']214 self.assertTrue(cidr.endswith(str(prefixlen)))215 @test.idempotent_id('a64af292-ec52-4bde-b654-a6984acaf477')216 def test_create_subnet_from_pool_with_quota(self):217 pool_values = {'default_quota': 4}218 subnet_values = {"prefixlen": self.max_prefixlen}219 pool_id, subnet = self._create_subnet_from_pool(220 subnet_values=subnet_values, pool_values=pool_values)221 cidr = str(subnet['cidr'])222 self.assertEqual(pool_id, subnet['subnetpool_id'])223 self.assertTrue(cidr.endswith(str(self.max_prefixlen)))224 @test.idempotent_id('49b44c64-1619-4b29-b527-ffc3c3115dc4')225 @test.requires_ext(extension='address-scope', service='network')226 def test_create_subnetpool_associate_address_scope(self):227 address_scope = self.create_address_scope(228 name=data_utils.rand_name('smoke-address-scope'),229 ip_version=self._ip_version)230 created_subnetpool = self._create_subnetpool(231 address_scope_id=address_scope['id'])232 body = self.client.show_subnetpool(created_subnetpool['id'])233 self.assertEqual(address_scope['id'],234 body['subnetpool']['address_scope_id'])235 @test.idempotent_id('910b6393-db24-4f6f-87dc-b36892ad6c8c')236 @test.requires_ext(extension='address-scope', service='network')237 def test_update_subnetpool_associate_address_scope(self):238 address_scope = self.create_address_scope(239 name=data_utils.rand_name('smoke-address-scope'),240 ip_version=self._ip_version)241 created_subnetpool = self._create_subnetpool()242 pool_id = created_subnetpool['id']243 body = self.client.show_subnetpool(pool_id)244 self.assertIsNone(body['subnetpool']['address_scope_id'])245 self.client.update_subnetpool(pool_id,246 address_scope_id=address_scope['id'])247 body = self.client.show_subnetpool(pool_id)248 self.assertEqual(address_scope['id'],249 body['subnetpool']['address_scope_id'])250 @test.idempotent_id('18302e80-46a3-4563-82ac-ccd1dd57f652')251 @test.requires_ext(extension='address-scope', service='network')252 def test_update_subnetpool_associate_another_address_scope(self):253 address_scope = self.create_address_scope(254 name=data_utils.rand_name('smoke-address-scope'),255 ip_version=self._ip_version)256 another_address_scope = self.create_address_scope(257 name=data_utils.rand_name('smoke-address-scope'),258 ip_version=self._ip_version)259 created_subnetpool = self._create_subnetpool(260 address_scope_id=address_scope['id'])261 pool_id = created_subnetpool['id']262 body = self.client.show_subnetpool(pool_id)263 self.assertEqual(address_scope['id'],264 body['subnetpool']['address_scope_id'])265 self.client.update_subnetpool(266 pool_id, address_scope_id=another_address_scope['id'])267 body = self.client.show_subnetpool(pool_id)268 self.assertEqual(another_address_scope['id'],269 body['subnetpool']['address_scope_id'])270 @test.idempotent_id('f8970048-e41b-42d6-934b-a1297b07706a')271 @test.requires_ext(extension='address-scope', service='network')272 def test_update_subnetpool_disassociate_address_scope(self):273 address_scope = self.create_address_scope(274 name=data_utils.rand_name('smoke-address-scope'),275 ip_version=self._ip_version)276 created_subnetpool = self._create_subnetpool(277 address_scope_id=address_scope['id'])278 pool_id = created_subnetpool['id']279 body = self.client.show_subnetpool(pool_id)280 self.assertEqual(address_scope['id'],281 body['subnetpool']['address_scope_id'])282 self.client.update_subnetpool(pool_id,283 address_scope_id=None)284 body = self.client.show_subnetpool(pool_id)285 self.assertIsNone(body['subnetpool']['address_scope_id'])286class SubnetPoolsTestV6(SubnetPoolsTest):287 min_prefixlen = '48'288 max_prefixlen = '64'289 _ip_version = 6290 subnet_cidr = '2001:db8:3::/64'291 new_prefix = u'2001:db8:5::/64'292 larger_prefix = u'2001:db8::/32'293 @classmethod294 def resource_setup(cls):295 super(SubnetPoolsTestV6, cls).resource_setup()296 min_prefixlen = '64'297 prefixes = [u'2001:db8:3::/48']298 cls._subnetpool_data = {'min_prefixlen': min_prefixlen,...
Check out the latest blogs from LambdaTest on this topic:
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
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!!