Best Python code snippet using tempest_python
test_nuage_bidirectional_fip_rate_limit_cli.py
Source:test_nuage_bidirectional_fip_rate_limit_cli.py  
...134            self.update_floating_ip_with_args(135                floatingip_id, '--nuage-ingress-fip-rate-kbps',136                str(ingress_rate_limit), '--nuage-egress-fip-rate-kbps',137                str(ingress_rate_limit))138        updated_floating_ip = self.show_floating_ip(floatingip_id)139        # Then I got a valid OpenStack FIP with the default rate limit140        self._verify_fip_openstack(port, updated_floating_ip,141                                   ingress_rate_limit, egress_rate_limit)142        # Then I got a valid VSD FIP with the default rate limit143        self._verify_fip_vsd(subnet, port, updated_floating_ip,144                             ingress_rate_limit, egress_rate_limit)145    @nuage_test.header()146    def test_create_fip_without_rate_limit(self):147        self._as_admin()148        network = self.create_network()149        subnet = self.create_subnet_with_args(network['name'], '10.0.0.0/24')150        router = self.create_router()151        self.set_router_gateway_with_args(router['id'], self.ext_net_id)152        self.add_router_interface_with_args(router['id'], subnet['id'])153        port = self.create_port_with_args(network['name'])154        created_floating_ip = self.create_floating_ip_with_args(155            self.ext_net_id, '--port-id', port['id'])156        self.addCleanup(self._delete_floating_ip,157                        created_floating_ip['id'])158        show_floating_ip = self.show_floating_ip(created_floating_ip['id'])159        # Then I got a valid OpenStack FIP with the default rate limit160        self._verify_fip_openstack(port, show_floating_ip,161                                   self.expected_default_fip_rate,162                                   self.expected_default_fip_rate)163        # Then I got a valid VSD FIP with the default rate limit164        self._verify_fip_vsd(165            subnet, port, created_floating_ip,166            self.expected_default_fip_rate, self.expected_default_fip_rate)167    @nuage_test.header()168    def test_create_update_fip_with_rate_limit_normal_value_ingress(self):169        #     """170        #     neutron net-create net1171        #     neutron subnet-create net1 10.0.0.0/24172        #173        #     neutron router-create router1174        #     neutron router-gateway-set router1 <thePublicNetworkID>175        #     neutron router-interface-add router1 <theSubnetID>176        #177        #     port-create net1178        #     floatingip-create public --port-id <thePortID> --nuage-fip-rate179        #         <theRateLimit>180        #     """181        self._as_admin()182        network = self.create_network()183        subnet = self.create_subnet_with_args(network['name'], '10.1.0.0/24')184        router = self.create_router()185        self.set_router_gateway_with_args(router['id'], self.ext_net_id)186        self.add_router_interface_with_args(router['id'], subnet['id'])187        port = self.create_port_with_args(network['name'])188        # Do it on ingress first189        rate_limit = 2000190        created_floating_ip = self.create_floating_ip_with_args(191            self.ext_net_id, '--port-id', port['id'],192            '--nuage-ingress-fip-rate-kbps', str(rate_limit))193        self.addCleanup(self._delete_floating_ip,194                        created_floating_ip['id'])195        show_floating_ip = self.show_floating_ip(created_floating_ip['id'])196        # Then I got a valid OpenStack FIP with the default rate limit197        self._verify_fip_openstack(port, show_floating_ip,198                                   ingress_rate_limit=rate_limit)199        # Then I got a valid VSD FIP with the default rate limit200        self._verify_fip_vsd(subnet, port, created_floating_ip,201                             ingress_rate_limit=rate_limit)202        # Update value203        updated_rate_limit = 4500204        self._update_fip_rate_limit(subnet, port, created_floating_ip['id'],205                                    ingress_rate_limit=updated_rate_limit,206                                    egress_rate_limit=updated_rate_limit)207    @nuage_test.header()208    def test_create_update_fip_with_rate_limit_normal_value_egress(self):209        #     """210        #     neutron net-create net1211        #     neutron subnet-create net1 10.0.0.0/24212        #213        #     neutron router-create router1214        #     neutron router-gateway-set router1 <thePublicNetworkID>215        #     neutron router-interface-add router1 <theSubnetID>216        #217        #     port-create net1218        #     floatingip-create public --port-id <thePortID> --nuage-fip-rate219        #         <theRateLimit>220        #     """221        self._as_admin()222        network = self.create_network()223        subnet = self.create_subnet_with_args(network['name'], '10.1.0.0/24')224        router = self.create_router()225        self.set_router_gateway_with_args(router['id'], self.ext_net_id)226        self.add_router_interface_with_args(router['id'], subnet['id'])227        port = self.create_port_with_args(network['name'])228        # Do it on egress first229        rate_limit = 2000230        created_floating_ip = self.create_floating_ip_with_args(231            self.ext_net_id, '--port-id', port['id'],232            '--nuage-egress-fip-rate-kbps', str(rate_limit))233        self.addCleanup(self._delete_floating_ip,234                        created_floating_ip['id'])235        show_floating_ip = self.show_floating_ip(created_floating_ip['id'])236        # Then I got a valid OpenStack FIP with the default rate limit237        self._verify_fip_openstack(port, show_floating_ip,238                                   egress_rate_limit=rate_limit)239        # Then I got a valid VSD FIP with the default rate limit240        self._verify_fip_vsd(subnet, port, created_floating_ip,241                             egress_rate_limit=rate_limit)242        # Update value243        updated_rate_limit = 4500244        self._update_fip_rate_limit(subnet, port, created_floating_ip['id'],245                                    ingress_rate_limit=updated_rate_limit,246                                    egress_rate_limit=updated_rate_limit)247class TestNuageBidiFRLCliWDefUnlimited(TestNuageBidiFRLCliWODefault):248    configured_default_fip_rate = constants.UNLIMITED249    expected_default_fip_rate = constants.UNLIMITED250class TestNuageBidiFRLCliWDef(TestNuageBidiFRLCliWODefault):251    configured_default_fip_rate = 321252    expected_default_fip_rate = configured_default_fip_rate253    @nuage_test.header()254    def test_create_fip_with_default_rate_limit_max_value(self):255        network = self.create_network()256        subnet = self.create_subnet_with_args(network['name'], '10.3.0.0/24')257        router = self.create_router()258        self.set_router_gateway_with_args(router['id'], self.ext_net_id)259        self.add_router_interface_with_args(router['id'], subnet['id'])260        port = self.create_port_with_args(network['name'])261        rate_limit = constants.MAX_INT262        created_floating_ip = self.create_floating_ip_with_args(263            self.ext_net_id, '--port-id', port['id'],264            '--nuage-ingress-fip-rate-kbps', str(rate_limit),265            '--nuage-egress-fip-rate-kbps', str(rate_limit))266        self.addCleanup(self._delete_floating_ip,267                        created_floating_ip['id'])268        show_floating_ip = self.show_floating_ip(created_floating_ip['id'])269        # Then I got a valid OpenStack FIP with the default rate limit270        self._verify_fip_openstack(port, show_floating_ip, rate_limit,271                                   rate_limit)272        # Then I got a valid VSD FIP with the default rate limit273        self._verify_fip_vsd(subnet, port, created_floating_ip,274                             rate_limit, rate_limit)275    @nuage_test.header()276    def test_create_fip_with_default_rate_limit_unlimited(self):277        network = self.create_network()278        subnet = self.create_subnet_with_args(network['name'], '10.4.0.0/24')279        router = self.create_router()280        self.set_router_gateway_with_args(router['id'], self.ext_net_id)281        self.add_router_interface_with_args(router['id'], subnet['id'])282        port = self.create_port_with_args(network['name'])283        rate_limit = constants.UNLIMITED284        created_floating_ip = self.create_floating_ip_with_args(285            self.ext_net_id, '--port-id', port['id'],286            '--nuage-ingress-fip-rate-kbps', str(rate_limit),287            '--nuage-egress-fip-rate-kbps', str(rate_limit))288        self.addCleanup(self._delete_floating_ip,289                        created_floating_ip['id'])290        show_floating_ip = self.show_floating_ip(created_floating_ip['id'])291        # Then I got a valid OpenStack FIP with the default rate limit292        self._verify_fip_openstack(port, show_floating_ip, rate_limit,293                                   rate_limit)294        # Then I got a valid VSD FIP with the default rate limit295        self._verify_fip_vsd(296            subnet, port, created_floating_ip, rate_limit, rate_limit)297    @nuage_test.header()298    def test_create_update_fip_rate_limit_with_keyword_default(self):299        network = self.create_network()300        subnet = self.create_subnet_with_args(network['name'], '10.5.0.0/24')301        router = self.create_router()302        self.set_router_gateway_with_args(router['id'], self.ext_net_id)303        self.add_router_interface_with_args(router['id'], subnet['id'])304        port = self.create_port_with_args(network['name'])305        # create using 'default' keyword306        ################################307        created_floating_ip = self.create_floating_ip_with_args(308            self.ext_net_id, '--port-id', port['id'],309            '--nuage-ingress-fip-rate-kbps',310            'default', '--nuage-egress-fip-rate-kbps', 'default')311        show_floating_ip = self.show_floating_ip(created_floating_ip['id'])312        # Then I got a valid OpenStack FIP with the default rate limit313        self._verify_fip_openstack(port, show_floating_ip,314                                   self.expected_default_fip_rate,315                                   self.expected_default_fip_rate)316        # Then I got a valid VSD FIP with the default rate limit317        self._verify_fip_vsd(318            subnet, port, created_floating_ip,319            self.expected_default_fip_rate, self.expected_default_fip_rate)320        # # Update to non-default value321        # ################################322        rate_limit = -1323        self._update_fip_rate_limit(subnet, port, created_floating_ip['id'],324                                    rate_limit, rate_limit)325        # # Update to non-default value326        # ################################327        rate_limit = 568328        self._update_fip_rate_limit(subnet, port, created_floating_ip['id'],329                                    rate_limit, rate_limit)330        # # Update using keyword 'default'331        # ################################332        # rate_limit = 'default'333        self.update_floating_ip_with_args(created_floating_ip['id'],334                                          '--nuage-ingress-fip-rate-kbps',335                                          'default',336                                          '--nuage-egress-fip-rate-kbps',337                                          'default')338        updated_floating_ip = self.show_floating_ip(created_floating_ip['id'])339        # Then I got a valid OpenStack FIP with the default rate limit340        self._verify_fip_openstack(port, updated_floating_ip,341                                   self.expected_default_fip_rate,342                                   self.expected_default_fip_rate)343        # Then I got a valid VSD FIP with the default rate limit344        self._verify_fip_vsd(345            subnet, port, updated_floating_ip,346            self.expected_default_fip_rate, self.expected_default_fip_rate)347    @nuage_test.header()348    @decorators.attr(type=['negative'])349    def test_create_fip_without_a_value(self):350        network = self.create_network()351        subnet = self.create_subnet_with_args(network['name'], '10.6.0.0/24')352        router = self.create_router()...test_floating_ips.py
Source:test_floating_ips.py  
...81        self.assertEqual(create_floating_ip['floating_network_id'],82                         self.ext_net_id)83        self.addCleanup(self._delete_floating_ip, create_floating_ip['id'])84        # Verifies the details of a floating_ip85        resp, floating_ip = self.client.show_floating_ip(86            create_floating_ip['id'])87        self.assertEqual('200', resp['status'])88        show_floating_ip = floating_ip['floatingip']89        self.assertEqual(show_floating_ip['id'], create_floating_ip['id'])90        self.assertEqual(show_floating_ip['floating_network_id'],91                         self.ext_net_id)92        self.assertEqual(show_floating_ip['tenant_id'],93                         create_floating_ip['tenant_id'])94        self.assertEqual(show_floating_ip['floating_ip_address'],95                         create_floating_ip['floating_ip_address'])96        self.assertEqual(show_floating_ip['port_id'], self.port[0]['id'])97        # Verify the floating ip exists in the list of all floating_ips98        resp, floating_ips = self.client.list_floating_ips()99        self.assertEqual('200', resp['status'])...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!!
