Best Python code snippet using tempest_python
test_readonly_neutron.py
Source:test_readonly_neutron.py  
...32                          self.neutron,33                          'this-does-not-exist')34    def test_neutron_net_list(self):35        net_list = self.parser.listing(self.neutron('net-list'))36        self.assertTableStruct(net_list, ['id', 'name', 'subnets'])37    def test_neutron_ext_list(self):38        ext = self.parser.listing(self.neutron('ext-list'))39        self.assertTableStruct(ext, ['alias', 'name'])40    def test_neutron_dhcp_agent_list_hosting_net(self):41        self.neutron('dhcp-agent-list-hosting-net',42                     params='private')43    def test_neutron_agent_list(self):44        agents = self.parser.listing(self.neutron('agent-list'))45        field_names = ['id', 'agent_type', 'host', 'alive', 'admin_state_up']46        self.assertTableStruct(agents, field_names)47    def test_neutron_floatingip_list(self):48        self.neutron('floatingip-list')49    def test_neutron_meter_label_list(self):50        self.neutron('meter-label-list')51    def test_neutron_meter_label_rule_list(self):52        self.neutron('meter-label-rule-list')53    def _test_neutron_lbaas_command(self, command):54        try:55            self.neutron(command)56        except exceptions.CommandFailed as e:57            if '404 Not Found' not in e.stderr:58                self.fail('%s: Unexpected failure.' % command)59    def test_neutron_lb_healthmonitor_list(self):60        self._test_neutron_lbaas_command('lb-healthmonitor-list')61    def test_neutron_lb_member_list(self):62        self._test_neutron_lbaas_command('lb-member-list')63    def test_neutron_lb_pool_list(self):64        self._test_neutron_lbaas_command('lb-pool-list')65    def test_neutron_lb_vip_list(self):66        self._test_neutron_lbaas_command('lb-vip-list')67    def test_neutron_net_external_list(self):68        net_ext_list = self.parser.listing(self.neutron('net-external-list'))69        self.assertTableStruct(net_ext_list, ['id', 'name', 'subnets'])70    def test_neutron_port_list(self):71        port_list = self.parser.listing(self.neutron('port-list'))72        self.assertTableStruct(port_list, ['id', 'name', 'mac_address',73                                           'fixed_ips'])74    def test_neutron_quota_list(self):75        self.neutron('quota-list')76    def test_neutron_router_list(self):77        router_list = self.parser.listing(self.neutron('router-list'))78        self.assertTableStruct(router_list, ['id', 'name',79                                             'external_gateway_info'])80    def test_neutron_security_group_list(self):81        security_grp = self.parser.listing(self.neutron('security-group-list'))82        self.assertTableStruct(security_grp, ['id', 'name',83                                              'security_group_rules'])84    def test_neutron_security_group_rule_list(self):85        security_grp = self.parser.listing(self.neutron86                                           ('security-group-rule-list'))87        self.assertTableStruct(security_grp, ['id', 'security_group',88                                              'direction', 'ethertype',89                                              'protocol/port', 'remote'])90    def test_neutron_subnet_list(self):91        subnet_list = self.parser.listing(self.neutron('subnet-list'))92        self.assertTableStruct(subnet_list, ['id', 'name', 'cidr',93                                             'allocation_pools'])94    def test_neutron_vpn_ikepolicy_list(self):95        ikepolicy = self.parser.listing(self.neutron('vpn-ikepolicy-list'))96        self.assertTableStruct(ikepolicy, ['id', 'name',97                                           'auth_algorithm',98                                           'encryption_algorithm',99                                           'ike_version', 'pfs'])100    def test_neutron_vpn_ipsecpolicy_list(self):101        ipsecpolicy = self.parser.listing(self.neutron('vpn-ipsecpolicy-list'))102        self.assertTableStruct(ipsecpolicy, ['id', 'name',103                                             'auth_algorithm',104                                             'encryption_algorithm',105                                             'pfs'])106    def test_neutron_vpn_service_list(self):107        vpn_list = self.parser.listing(self.neutron('vpn-service-list'))108        self.assertTableStruct(vpn_list, ['id', 'name',109                                          'router_id', 'status'])110    def test_neutron_ipsec_site_connection_list(self):111        ipsec_site = self.parser.listing(self.neutron112                                         ('ipsec-site-connection-list'))113        self.assertTableStruct(ipsec_site, ['id', 'name',114                                            'peer_address',115                                            'peer_cidrs',116                                            'route_mode',117                                            'auth_mode', 'status'])118    def test_neutron_firewall_list(self):119        firewall_list = self.parser.listing(self.neutron120                                            ('firewall-list'))121        self.assertTableStruct(firewall_list, ['id', 'name',122                                               'firewall_policy_id'])123    def test_neutron_firewall_policy_list(self):124        firewall_policy = self.parser.listing(self.neutron125                                              ('firewall-policy-list'))126        self.assertTableStruct(firewall_policy, ['id', 'name',127                                                 'firewall_rules'])128    def test_neutron_firewall_rule_list(self):129        firewall_rule = self.parser.listing(self.neutron130                                            ('firewall-rule-list'))131        self.assertTableStruct(firewall_rule, ['id', 'name',132                                               'firewall_policy_id',133                                               'summary', 'enabled'])134    def test_neutron_help(self):135        help_text = self.neutron('help')136        lines = help_text.split('\n')137        self.assertFirstLineStartsWith(lines, 'usage: neutron')138        commands = []139        cmds_start = lines.index('Commands for API v2.0:')140        command_pattern = re.compile('^ {2}([a-z0-9\-\_]+)')141        for line in lines[cmds_start:]:142            match = command_pattern.match(line)143            if match:144                commands.append(match.group(1))145        commands = set(commands)...test_cli.py
Source:test_cli.py  
...52            self.assertIn('region', svc.keys())53    def test_admin_endpoint_list(self):54        out = self.keystone('endpoint-list')55        endpoints = self.parser.listing(out)56        self.assertTableStruct(endpoints, [57            'id', 'region', 'publicurl', 'internalurl',58            'adminurl', 'service_id'])59    def test_admin_endpoint_service_match(self):60        endpoints = self.parser.listing(self.keystone('endpoint-list'))61        services = self.parser.listing(self.keystone('service-list'))62        svc_by_id = {}63        for svc in services:64            svc_by_id[svc['id']] = svc65        for endpoint in endpoints:66            self.assertIn(endpoint['service_id'], svc_by_id)67    def test_admin_role_list(self):68        roles = self.parser.listing(self.keystone('role-list'))69        self.assertTableStruct(roles, ['id', 'name'])70    def test_admin_service_list(self):71        services = self.parser.listing(self.keystone('service-list'))72        self.assertTableStruct(services, ['id', 'name', 'type', 'description'])73    def test_admin_tenant_list(self):74        tenants = self.parser.listing(self.keystone('tenant-list'))75        self.assertTableStruct(tenants, ['id', 'name', 'enabled'])76    def test_admin_user_list(self):77        users = self.parser.listing(self.keystone('user-list'))78        self.assertTableStruct(users, [79            'id', 'name', 'enabled', 'email'])80    def test_admin_user_role_list(self):81        user_roles = self.parser.listing(self.keystone('user-role-list'))82        self.assertTableStruct(user_roles, [83            'id', 'name', 'user_id', 'tenant_id'])84    def test_admin_discover(self):85        discovered = self.keystone('discover')86        self.assertIn('Keystone found at http', discovered)87        self.assertIn('supports version', discovered)88    def test_admin_help(self):89        help_text = self.keystone('help')90        lines = help_text.split('\n')91        self.assertFirstLineStartsWith(lines, 'usage: keystone')92        commands = []93        cmds_start = lines.index('Positional arguments:')94        cmds_end = lines.index('Optional arguments:')95        command_pattern = re.compile('^ {4}([a-z0-9\-\_]+)')96        for line in lines[cmds_start:cmds_end]:97            match = command_pattern.match(line)98            if match:99                commands.append(match.group(1))100        commands = set(commands)101        wanted_commands = set(('catalog', 'endpoint-list', 'help',102                               'token-get', 'discover', 'bootstrap'))103        self.assertFalse(wanted_commands - commands)104    def test_admin_bashcompletion(self):105        self.keystone('bash-completion')106    def test_admin_ec2_credentials_list(self):107        creds = self.keystone('ec2-credentials-list')108        creds = self.parser.listing(creds)109        self.assertTableStruct(creds, ['tenant', 'access', 'secret'])110    # Optional arguments:111    def test_admin_version(self):112        self.keystone('', flags='--version')113    def test_admin_debug_list(self):114        self.keystone('catalog', flags='--debug')115    def test_admin_timeout(self):...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!!
