How to use list_subnetpools method in tempest

Best Python code snippet using tempest_python

test_kuryr_ipam.py

Source:test_kuryr_ipam.py Github

copy

Full Screen

...60 fake_name = pool_name61 kuryr_subnetpools = self._get_fake_v4_subnetpools(62 fake_kuryr_subnetpool_id, prefixes=[FAKE_IP4_CIDR],63 name=fake_name)64 app.neutron.list_subnetpools(name=fake_name).AndReturn(65 {'subnetpools': []})66 fake_subnetpool_response = {67 'subnetpool': kuryr_subnetpools['subnetpools'][0]68 }69 self.mox.StubOutWithMock(app.neutron, 'create_subnetpool')70 app.neutron.create_subnetpool(71 {'subnetpool': new_subnetpool}).AndReturn(fake_subnetpool_response)72 self.mox.ReplayAll()73 fake_request = {74 'AddressSpace': '',75 'Pool': FAKE_IP4_CIDR,76 'SubPool': '', # In the case --ip-range is not given77 'Options': {},78 'V6': False79 }80 response = self.app.post('/IpamDriver.RequestPool',81 content_type='application/json',82 data=jsonutils.dumps(fake_request))83 self.assertEqual(200, response.status_code)84 decoded_json = jsonutils.loads(response.data)85 self.assertEqual(fake_kuryr_subnetpool_id, decoded_json['PoolID'])86 def test_ipam_driver_request_pool_with_pool_name_option(self):87 fake_subnet = {"subnets": []}88 self.mox.StubOutWithMock(app.neutron, 'list_subnets')89 app.neutron.list_subnets(cidr=FAKE_IP4_CIDR).AndReturn(90 fake_subnet)91 self.mox.StubOutWithMock(app.neutron, 'list_subnetpools')92 fake_kuryr_subnetpool_id = str(uuid.uuid4())93 fake_name = 'fake_pool_name'94 new_subnetpool = {95 'name': fake_name,96 'default_prefixlen': 16,97 'prefixes': [FAKE_IP4_CIDR]}98 kuryr_subnetpools = self._get_fake_v4_subnetpools(99 fake_kuryr_subnetpool_id, prefixes=[FAKE_IP4_CIDR],100 name=fake_name)101 fake_subnetpool_response = {102 'subnetpool': kuryr_subnetpools['subnetpools'][0]103 }104 self.mox.StubOutWithMock(app.neutron, 'create_subnetpool')105 app.neutron.create_subnetpool(106 {'subnetpool': new_subnetpool}).AndReturn(fake_subnetpool_response)107 self.mox.ReplayAll()108 fake_request = {109 'AddressSpace': '',110 'Pool': FAKE_IP4_CIDR,111 'SubPool': '', # In the case --ip-range is not given112 'Options': {'neutron.pool.name': 'fake_pool_name'},113 'V6': False114 }115 response = self.app.post('/IpamDriver.RequestPool',116 content_type='application/json',117 data=jsonutils.dumps(fake_request))118 self.assertEqual(200, response.status_code)119 decoded_json = jsonutils.loads(response.data)120 self.assertEqual(fake_kuryr_subnetpool_id, decoded_json['PoolID'])121 def test_ipam_driver_request_pool_with_default_v6pool(self):122 self.mox.StubOutWithMock(app.neutron, 'list_subnetpools')123 fake_kuryr_subnetpool_id = str(uuid.uuid4())124 fake_name = 'kuryr6'125 kuryr_subnetpools = self._get_fake_v6_subnetpools(126 fake_kuryr_subnetpool_id, prefixes=['fe80::/64'])127 app.neutron.list_subnetpools(name=fake_name).AndReturn(128 {'subnetpools': kuryr_subnetpools['subnetpools']})129 self.mox.ReplayAll()130 fake_request = {131 'AddressSpace': '',132 'Pool': '',133 'SubPool': '', # In the case --ip-range is not given134 'Options': {},135 'V6': True136 }137 response = self.app.post('/IpamDriver.RequestPool',138 content_type='application/json',139 data=jsonutils.dumps(fake_request))140 self.assertEqual(200, response.status_code)141 decoded_json = jsonutils.loads(response.data)142 self.assertEqual(fake_kuryr_subnetpool_id, decoded_json['PoolID'])143 def test_ipam_driver_release_pool(self):144 fake_kuryr_subnetpool_id = str(uuid.uuid4())145 self.mox.StubOutWithMock(app.neutron, 'delete_subnetpool')146 app.neutron.delete_subnetpool(fake_kuryr_subnetpool_id).AndReturn(147 {})148 self.mox.ReplayAll()149 fake_request = {150 'PoolID': fake_kuryr_subnetpool_id151 }152 response = self.app.post('/IpamDriver.ReleasePool',153 content_type='application/json',154 data=jsonutils.dumps(fake_request))155 self.assertEqual(200, response.status_code)156 def test_ipam_driver_request_address(self):157 # faking list_subnetpools158 self.mox.StubOutWithMock(app.neutron, 'list_subnetpools')159 fake_kuryr_subnetpool_id = str(uuid.uuid4())160 fake_name = lib_utils.get_neutron_subnetpool_name(FAKE_IP4_CIDR)161 kuryr_subnetpools = self._get_fake_v4_subnetpools(162 fake_kuryr_subnetpool_id, prefixes=[FAKE_IP4_CIDR],163 name=fake_name)164 app.neutron.list_subnetpools(id=fake_kuryr_subnetpool_id).AndReturn(165 kuryr_subnetpools)166 # faking list_subnets167 docker_endpoint_id = lib_utils.get_hash()168 neutron_network_id = str(uuid.uuid4())169 subnet_v4_id = str(uuid.uuid4())170 fake_v4_subnet = self._get_fake_v4_subnet(171 neutron_network_id, docker_endpoint_id, subnet_v4_id,172 subnetpool_id=fake_kuryr_subnetpool_id,173 cidr=FAKE_IP4_CIDR)174 fake_subnet_response = {175 'subnets': [176 fake_v4_subnet['subnet']177 ]178 }179 self.mox.StubOutWithMock(app.neutron, 'list_subnets')180 app.neutron.list_subnets(cidr=FAKE_IP4_CIDR).AndReturn(181 fake_subnet_response)182 # faking create_port183 fake_neutron_port_id = str(uuid.uuid4())184 fake_port = base.TestKuryrBase._get_fake_port(185 docker_endpoint_id, neutron_network_id,186 fake_neutron_port_id, lib_const.PORT_STATUS_ACTIVE,187 subnet_v4_id,188 neutron_subnet_v4_address="10.0.0.5")189 port_request = {190 'name': 'kuryr-unbound-port',191 'admin_state_up': True,192 'network_id': neutron_network_id,193 'binding:host_id': lib_utils.get_hostname(),194 }195 fixed_ips = port_request['fixed_ips'] = []196 fixed_ip = {'subnet_id': subnet_v4_id}197 fixed_ips.append(fixed_ip)198 self.mox.StubOutWithMock(app.neutron, 'create_port')199 app.neutron.create_port({'port': port_request}).AndReturn(fake_port)200 # Apply mocks201 self.mox.ReplayAll()202 # Testing container ip allocation203 fake_request = {204 'PoolID': fake_kuryr_subnetpool_id,205 'Address': '', # Querying for container address206 'Options': {}207 }208 response = self.app.post('/IpamDriver.RequestAddress',209 content_type='application/json',210 data=jsonutils.dumps(fake_request))211 self.assertEqual(200, response.status_code)212 decoded_json = jsonutils.loads(response.data)213 self.assertEqual('10.0.0.5/16', decoded_json['Address'])214 def test_ipam_driver_request_address_when_subnet_not_exist(self):215 requested_address = '10.0.0.5'216 # faking list_subnetpools217 self.mox.StubOutWithMock(app.neutron, 'list_subnetpools')218 fake_kuryr_subnetpool_id = str(uuid.uuid4())219 fake_name = lib_utils.get_neutron_subnetpool_name(FAKE_IP4_CIDR)220 kuryr_subnetpools = self._get_fake_v4_subnetpools(221 fake_kuryr_subnetpool_id, prefixes=[FAKE_IP4_CIDR],222 name=fake_name)223 app.neutron.list_subnetpools(id=fake_kuryr_subnetpool_id).AndReturn(224 kuryr_subnetpools)225 # faking list_subnets226 fake_subnet_response = {'subnets': []}227 self.mox.StubOutWithMock(app.neutron, 'list_subnets')228 app.neutron.list_subnets(cidr=FAKE_IP4_CIDR).AndReturn(229 fake_subnet_response)230 # Apply mocks231 self.mox.ReplayAll()232 # Testing container ip allocation233 fake_request = {234 'PoolID': fake_kuryr_subnetpool_id,235 'Address': requested_address,236 'Options': {}237 }238 response = self.app.post('/IpamDriver.RequestAddress',239 content_type='application/json',240 data=jsonutils.dumps(fake_request))241 self.assertEqual(200, response.status_code)242 decoded_json = jsonutils.loads(response.data)243 self.assertEqual(requested_address + '/16', decoded_json['Address'])244 @ddt.data((False), (True))245 def test_ipam_driver_request_specific_address(self, existing_port):246 requested_address = '10.0.0.5'247 # faking list_subnetpools248 self.mox.StubOutWithMock(app.neutron, 'list_subnetpools')249 fake_kuryr_subnetpool_id = str(uuid.uuid4())250 fake_name = lib_utils.get_neutron_subnetpool_name(FAKE_IP4_CIDR)251 kuryr_subnetpools = self._get_fake_v4_subnetpools(252 fake_kuryr_subnetpool_id, prefixes=[FAKE_IP4_CIDR],253 name=fake_name)254 app.neutron.list_subnetpools(id=fake_kuryr_subnetpool_id).AndReturn(255 kuryr_subnetpools)256 # faking list_subnets257 docker_endpoint_id = lib_utils.get_hash()258 neutron_network_id = str(uuid.uuid4())259 subnet_v4_id = str(uuid.uuid4())260 fake_v4_subnet = self._get_fake_v4_subnet(261 neutron_network_id, docker_endpoint_id, subnet_v4_id,262 subnetpool_id=fake_kuryr_subnetpool_id,263 cidr=FAKE_IP4_CIDR)264 fake_subnet_response = {265 'subnets': [266 fake_v4_subnet['subnet']267 ]268 }269 self.mox.StubOutWithMock(app.neutron, 'list_subnets')270 app.neutron.list_subnets(cidr=FAKE_IP4_CIDR).AndReturn(271 fake_subnet_response)272 self.mox.StubOutWithMock(app.neutron, 'list_ports')273 # faking update_port or create_port274 fake_neutron_port_id = str(uuid.uuid4())275 fake_port = base.TestKuryrBase._get_fake_port(276 docker_endpoint_id, neutron_network_id,277 fake_neutron_port_id, lib_const.PORT_STATUS_ACTIVE,278 subnet_v4_id,279 neutron_subnet_v4_address=requested_address)280 fixed_ip_existing = [('subnet_id=%s' % subnet_v4_id)]281 if existing_port:282 fake_existing_port = fake_port['port']283 fake_existing_port['binding:host_id'] = ''284 fake_existing_port['binding:vif_type'] = 'unbound'285 fake_ports_response = {'ports': [fake_existing_port]}286 else:287 fake_ports_response = {'ports': []}288 fixed_ip_existing.append('ip_address=%s' % requested_address)289 app.neutron.list_ports(fixed_ips=fixed_ip_existing).AndReturn(290 fake_ports_response)291 if existing_port:292 update_port = {293 'admin_state_up': True,294 'binding:host_id': lib_utils.get_hostname(),295 }296 self.mox.StubOutWithMock(app.neutron, 'update_port')297 app.neutron.update_port(fake_neutron_port_id,298 {'port': update_port}).AndReturn(299 fake_port)300 else:301 port_request = {302 'name': 'kuryr-unbound-port',303 'admin_state_up': True,304 'network_id': neutron_network_id,305 'binding:host_id': lib_utils.get_hostname(),306 }307 fixed_ips = port_request['fixed_ips'] = []308 fixed_ip = {'subnet_id': subnet_v4_id,309 'ip_address': requested_address}310 fixed_ips.append(fixed_ip)311 self.mox.StubOutWithMock(app.neutron, 'create_port')312 app.neutron.create_port({'port': port_request}).AndReturn(313 fake_port)314 # Apply mocks315 self.mox.ReplayAll()316 # Testing container ip allocation317 fake_request = {318 'PoolID': fake_kuryr_subnetpool_id,319 'Address': requested_address,320 'Options': {}321 }322 response = self.app.post('/IpamDriver.RequestAddress',323 content_type='application/json',324 data=jsonutils.dumps(fake_request))325 self.assertEqual(200, response.status_code)326 decoded_json = jsonutils.loads(response.data)327 self.assertEqual(requested_address + '/16', decoded_json['Address'])328 def test_ipam_driver_request_address_overlapping_cidr(self):329 # faking list_subnetpools330 self.mox.StubOutWithMock(app.neutron, 'list_subnetpools')331 fake_kuryr_subnetpool_id = str(uuid.uuid4())332 fake_kuryr_subnetpool_id2 = str(uuid.uuid4())333 fake_name = lib_utils.get_neutron_subnetpool_name(FAKE_IP4_CIDR)334 kuryr_subnetpools = self._get_fake_v4_subnetpools(335 fake_kuryr_subnetpool_id, prefixes=[FAKE_IP4_CIDR],336 name=fake_name)337 app.neutron.list_subnetpools(id=fake_kuryr_subnetpool_id).AndReturn(338 kuryr_subnetpools)339 # faking list_subnets340 docker_endpoint_id = lib_utils.get_hash()341 neutron_network_id = str(uuid.uuid4())342 neutron_network_id2 = str(uuid.uuid4())343 neutron_subnet_v4_id = str(uuid.uuid4())344 neutron_subnet_v4_id2 = str(uuid.uuid4())345 fake_v4_subnet = self._get_fake_v4_subnet(346 neutron_network_id, docker_endpoint_id, neutron_subnet_v4_id,347 subnetpool_id=fake_kuryr_subnetpool_id,348 cidr=FAKE_IP4_CIDR)349 fake_v4_subnet2 = self._get_fake_v4_subnet(350 neutron_network_id2, docker_endpoint_id, neutron_subnet_v4_id2,351 subnetpool_id=fake_kuryr_subnetpool_id2,352 cidr=FAKE_IP4_CIDR)353 fake_subnet_response = {354 'subnets': [355 fake_v4_subnet2['subnet'],356 fake_v4_subnet['subnet']357 ]358 }359 self.mox.StubOutWithMock(app.neutron, 'list_subnets')360 app.neutron.list_subnets(cidr=FAKE_IP4_CIDR).AndReturn(361 fake_subnet_response)362 # faking create_port363 fake_neutron_port_id = str(uuid.uuid4())364 fake_port = base.TestKuryrBase._get_fake_port(365 docker_endpoint_id, neutron_network_id,366 fake_neutron_port_id,367 neutron_subnet_v4_id=neutron_subnet_v4_id,368 neutron_subnet_v4_address="10.0.0.5")369 port_request = {370 'name': 'kuryr-unbound-port',371 'admin_state_up': True,372 'network_id': neutron_network_id,373 'binding:host_id': lib_utils.get_hostname(),374 }375 port_request['fixed_ips'] = []376 fixed_ip = {'subnet_id': neutron_subnet_v4_id}377 port_request['fixed_ips'].append(fixed_ip)378 self.mox.StubOutWithMock(app.neutron, 'create_port')379 app.neutron.create_port({'port': port_request}).AndReturn(fake_port)380 # Apply mocks381 self.mox.ReplayAll()382 # Testing container ip allocation383 fake_request = {384 'PoolID': fake_kuryr_subnetpool_id,385 'Address': '', # Querying for container address386 'Options': {}387 }388 response = self.app.post('/IpamDriver.RequestAddress',389 content_type='application/json',390 data=jsonutils.dumps(fake_request))391 self.assertEqual(200, response.status_code)392 decoded_json = jsonutils.loads(response.data)393 self.assertEqual('10.0.0.5/16', decoded_json['Address'])394 def test_ipam_driver_request_address_for_same_gateway(self):395 # faking list_subnetpools396 self.mox.StubOutWithMock(app.neutron, 'list_subnetpools')397 fake_kuryr_subnetpool_id = str(uuid.uuid4())398 fake_name = lib_utils.get_neutron_subnetpool_name(FAKE_IP4_CIDR)399 kuryr_subnetpools = self._get_fake_v4_subnetpools(400 fake_kuryr_subnetpool_id, prefixes=[FAKE_IP4_CIDR],401 name=fake_name)402 app.neutron.list_subnetpools(id=fake_kuryr_subnetpool_id).AndReturn(403 kuryr_subnetpools)404 # faking list_subnets405 docker_endpoint_id = lib_utils.get_hash()406 neutron_network_id = str(uuid.uuid4())407 subnet_v4_id = str(uuid.uuid4())408 fake_v4_subnet = self._get_fake_v4_subnet(409 neutron_network_id, docker_endpoint_id, subnet_v4_id,410 subnetpool_id=fake_kuryr_subnetpool_id,411 cidr=FAKE_IP4_CIDR)412 fake_v4_subnet['subnet'].update(gateway_ip='10.0.0.1')413 fake_subnet_response = {414 'subnets': [415 fake_v4_subnet['subnet']416 ]417 }418 self.mox.StubOutWithMock(app.neutron, 'list_subnets')419 app.neutron.list_subnets(cidr=FAKE_IP4_CIDR).AndReturn(420 fake_subnet_response)421 # Apply mocks422 self.mox.ReplayAll()423 # Testing container ip allocation424 fake_request = {425 'PoolID': fake_kuryr_subnetpool_id,426 'Address': '10.0.0.1',427 'Options': {428 const.REQUEST_ADDRESS_TYPE: const.NETWORK_GATEWAY_OPTIONS429 }430 }431 response = self.app.post('/IpamDriver.RequestAddress',432 content_type='application/json',433 data=jsonutils.dumps(fake_request))434 self.assertEqual(200, response.status_code)435 decoded_json = jsonutils.loads(response.data)436 self.assertEqual('10.0.0.1/16', decoded_json['Address'])437 def test_ipam_driver_request_address_for_different_gateway(self):438 # faking list_subnetpools439 self.mox.StubOutWithMock(app.neutron, 'list_subnetpools')440 fake_kuryr_subnetpool_id = str(uuid.uuid4())441 fake_name = lib_utils.get_neutron_subnetpool_name(FAKE_IP4_CIDR)442 kuryr_subnetpools = self._get_fake_v4_subnetpools(443 fake_kuryr_subnetpool_id, prefixes=[FAKE_IP4_CIDR],444 name=fake_name)445 app.neutron.list_subnetpools(id=fake_kuryr_subnetpool_id).AndReturn(446 kuryr_subnetpools)447 # faking list_subnets448 docker_endpoint_id = lib_utils.get_hash()449 neutron_network_id = str(uuid.uuid4())450 subnet_v4_id = str(uuid.uuid4())451 fake_v4_subnet = self._get_fake_v4_subnet(452 neutron_network_id, docker_endpoint_id, subnet_v4_id,453 subnetpool_id=fake_kuryr_subnetpool_id,454 cidr=FAKE_IP4_CIDR)455 fake_v4_subnet['subnet'].update(gateway_ip='10.0.0.1')456 fake_subnet_response = {457 'subnets': [458 fake_v4_subnet['subnet']459 ]460 }461 self.mox.StubOutWithMock(app.neutron, 'list_subnets')462 app.neutron.list_subnets(cidr=FAKE_IP4_CIDR).AndReturn(463 fake_subnet_response)464 # Apply mocks465 self.mox.ReplayAll()466 # Testing container ip allocation467 fake_request = {468 'PoolID': fake_kuryr_subnetpool_id,469 'Address': '10.0.0.5', # Different with existed gw ip470 'Options': {471 const.REQUEST_ADDRESS_TYPE: const.NETWORK_GATEWAY_OPTIONS472 }473 }474 response = self.app.post('/IpamDriver.RequestAddress',475 content_type='application/json',476 data=jsonutils.dumps(fake_request))477 self.assertEqual(500, response.status_code)478 decoded_json = jsonutils.loads(response.data)479 self.assertIn('Err', decoded_json)480 err_message = ("Requested gateway {0} does not match with "481 "gateway {1} in existed network.").format(482 '10.0.0.5', '10.0.0.1')483 self.assertEqual({'Err': err_message}, decoded_json)484 def test_ipam_driver_release_address(self):485 # faking list_subnetpools486 self.mox.StubOutWithMock(app.neutron, 'list_subnetpools')487 fake_kuryr_subnetpool_id = str(uuid.uuid4())488 fake_name = str('-'.join(['kuryrPool', FAKE_IP4_CIDR]))489 kuryr_subnetpools = self._get_fake_v4_subnetpools(490 fake_kuryr_subnetpool_id, prefixes=[FAKE_IP4_CIDR], name=fake_name)491 app.neutron.list_subnetpools(id=fake_kuryr_subnetpool_id).AndReturn(492 kuryr_subnetpools)493 fake_ip4 = '10.0.0.5'494 # faking list_subnets495 docker_network_id = lib_utils.get_hash()496 docker_endpoint_id = lib_utils.get_hash()497 neutron_network_id = docker_network_id = str(uuid.uuid4())498 subnet_v4_id = str(uuid.uuid4())499 fake_v4_subnet = self._get_fake_v4_subnet(500 docker_network_id, docker_endpoint_id, subnet_v4_id,501 subnetpool_id=fake_kuryr_subnetpool_id,502 cidr=FAKE_IP4_CIDR)503 fake_subnet_response = {504 'subnets': [505 fake_v4_subnet['subnet']...

Full Screen

Full Screen

test_subnetpools_rbac.py

Source:test_subnetpools_rbac.py Github

copy

Full Screen

...59 RBAC test for the neutron create_subnetpool:is_default policy60 """61 # Most likely we already have default subnetpools for ipv4 and ipv6,62 # so we temporary mark them as is_default=False, to let this test pass.63 def_pools = self.subnetpools_client.list_subnetpools(is_default=True)64 for default_pool in def_pools["subnetpools"]:65 self.subnetpools_client.update_subnetpool(default_pool["id"],66 is_default=False)67 self.addCleanup(self.subnetpools_client.update_subnetpool,68 default_pool["id"], is_default=True)69 with self.override_role():70 # It apparently only enforces the policy for is_default=True.71 # It does nothing for is_default=False72 self._create_subnetpool(is_default=True)73 @rbac_rule_validation.action(service="neutron",74 rules=["create_subnetpool",75 "create_subnetpool:shared"],76 expected_error_codes=[403, 403])77 @decorators.idempotent_id('cf730989-0d47-40bc-b39a-99e7de484723')78 def test_create_subnetpool_shared(self):79 """Create subnetpool shared.80 RBAC test for the neutron create_subnetpool:shared policy81 """82 with self.override_role():83 self._create_subnetpool(shared=True)84 @rbac_rule_validation.action(service="neutron",85 rules=["get_subnetpool"],86 expected_error_codes=[404])87 @decorators.idempotent_id('4f5aee26-0507-4b6d-b44c-3128a25094d2')88 def test_show_subnetpool(self):89 """Show subnetpool.90 RBAC test for the neutron get_subnetpool policy91 """92 subnetpool = self._create_subnetpool()93 with self.override_role():94 self.subnetpools_client.show_subnetpool(subnetpool['id'])95 @rbac_rule_validation.action(service="neutron",96 rules=["get_subnetpool",97 "update_subnetpool"],98 expected_error_codes=[404, 403])99 @decorators.idempotent_id('1e79cead-5081-4be2-a4f7-484c0f443b9b')100 def test_update_subnetpool(self):101 """Update subnetpool.102 RBAC test for the neutron update_subnetpool policy103 """104 subnetpool = self._create_subnetpool()105 with self.override_role():106 self.subnetpools_client.update_subnetpool(subnetpool['id'],107 min_prefixlen=24)108 @decorators.idempotent_id('a16f4e5c-0675-415f-b636-00af00638693')109 @rbac_rule_validation.action(service="neutron",110 rules=["update_subnetpool",111 "update_subnetpool:is_default"])112 def test_update_subnetpool_is_default(self):113 """Update default subnetpool.114 RBAC test for the neutron update_subnetpool:is_default policy115 """116 subnetpools = self.subnetpools_client.list_subnetpools()['subnetpools']117 default_pool = list(118 filter(lambda p: p['is_default'] is True, subnetpools))119 if default_pool:120 default_pool = default_pool[0]121 else:122 default_pool = self._create_subnetpool(is_default=True)123 original_desc = default_pool['description']124 with self.override_role():125 self.subnetpools_client.update_subnetpool(126 default_pool['id'], description=original_desc, is_default=True)127 @rbac_rule_validation.action(service="neutron",128 rules=["get_subnetpool",129 "delete_subnetpool"],130 expected_error_codes=[404, 403])131 @decorators.idempotent_id('50f5944e-43e5-457b-ab50-fb48a73f0d3e')132 def test_delete_subnetpool(self):133 """Delete subnetpool.134 RBAC test for the neutron delete_subnetpool policy135 """136 subnetpool = self._create_subnetpool()137 with self.override_role():138 self.subnetpools_client.delete_subnetpool(subnetpool['id'])139 @rbac_rule_validation.action(service="neutron", rules=["get_subnetpool"])140 @decorators.idempotent_id('f1caf0f6-bde5-11e8-a355-529269fb1459')141 def test_list_subnetpools(self):142 """List subnetpools.143 RBAC test for the neutron ``list_subnetpools`` function and144 the ``get_subnetpool`` policy145 """146 admin_resource_id = self._create_subnetpool()['id']147 with (self.override_role_and_validate_list(148 admin_resource_id=admin_resource_id)) as ctx:149 ctx.resources = self.subnetpools_client.list_subnetpools(...

Full Screen

Full Screen

test_ipam_pool.py

Source:test_ipam_pool.py Github

copy

Full Screen

...47 app.neutron.list_subnets(cidr="10.0.0.0/16").AndReturn(48 fake_subnet)49 self.mox.StubOutWithMock(app.neutron, 'list_subnetpools')50 fake_name = pool_name51 app.neutron.list_subnetpools(name=fake_name).AndReturn(52 {'subnetpools': []})53 self.mox.StubOutWithMock(app.neutron, 'create_subnetpool')54 app.neutron.create_subnetpool(55 {'subnetpool': new_subnetpool}).AndRaise(GivenException)56 self.mox.ReplayAll()57 pool = '10.0.0.0/16'58 response = self._invoke_create_request(pool)59 self.assertEqual(GivenException.status_code, response.status_code)60 decoded_json = jsonutils.loads(response.data)61 self.assertIn('Err', decoded_json)62 self.assertEqual(63 {'Err': GivenException.message}, decoded_json)64 def test_request_pool_bad_request_failure(self):65 pool = 'pool-should-be-cidr'66 response = self._invoke_create_request(pool)67 self.assertEqual(400, response.status_code)68 decoded_json = jsonutils.loads(response.data)69 self.assertIn('Err', decoded_json)70 self.assertIn(pool, decoded_json['Err'])71 self.assertIn('Pool', decoded_json['Err'])72 def test_request_pool_list_subnetpool_failure(self):73 fake_subnet = {"subnets": []}74 self.mox.StubOutWithMock(app.neutron, 'list_subnets')75 app.neutron.list_subnets(cidr='10.0.0.0/16').AndReturn(76 fake_subnet)77 self.mox.StubOutWithMock(app.neutron, 'list_subnetpools')78 pool_name = lib_utils.get_neutron_subnetpool_name("10.0.0.0/16")79 fake_name = pool_name80 ex = exceptions.Unauthorized81 app.neutron.list_subnetpools(name=fake_name).AndRaise(ex)82 self.mox.ReplayAll()83 pool = '10.0.0.0/16'84 response = self._invoke_create_request(pool)...

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