Best Python code snippet using tempest_python
test_cli20_l7policy.py
Source:test_cli20_l7policy.py  
...59        position_values = list(api_args.values())60        self._test_create_resource(resource, cmd, None, 'test_id',61                                   cli_args, position_names, position_values,62                                   cmd_resource=cmd_resource)63    def _test_update_policy(self, *args, **kwargs):64        resource = 'l7policy'65        cmd_resource = 'lbaas_l7policy'66        cmd = l7policy.UpdateL7Policy(test_cli20.MyApp(sys.stdout), None)67        cli_args, api_args = self._get_test_args(*args, **kwargs)68        cli_args.append('test_id')69        self._test_update_resource(resource, cmd, 'test_id',70                                   cli_args, api_args,71                                   cmd_resource=cmd_resource)72    def test_create_policy_with_mandatory_params(self):73        # lbaas-l7policy-create with mandatory params only.74        self._test_create_policy('action', 'listener')75    def test_create_policy_with_all_params(self):76        # lbaas-l7policy-create REJECT policy.77        self._test_create_policy('name', 'description',78                                 'action', 'listener',79                                 'position')80    def test_create_disabled_policy(self):81        # lbaas-l7policy-create disabled REJECT policy.82        self._test_create_policy('action', 'listener', 'admin-state-down')83    def test_create_url_redirect_policy(self):84        # lbaas-l7policy-create REDIRECT_TO_URL policy.85        self._test_create_policy('name', 'description',86                                 'action', 'listener',87                                 'redirect-url',88                                 action='REDIRECT_TO_URL')89    def test_create_url_redirect_policy_no_url(self):90        # lbaas-l7policy-create REDIRECT_TO_URL policy without url argument.91        self.assertRaises(exceptions.CommandError,92                          self._test_create_policy,93                          'name', 'description',94                          'action', 'listener',95                          action='REDIRECT_TO_URL')96    def test_create_pool_redirect_policy(self):97        # lbaas-l7policy-create REDIRECT_TO_POOL policy.98        self._test_create_policy('name', 'description',99                                 'action', 'listener',100                                 'redirect-pool',101                                 action='REDIRECT_TO_POOL')102    def test_create_pool_redirect_policy_no_pool(self):103        # lbaas-l7policy-create REDIRECT_TO_POOL policy without pool argument.104        self.assertRaises(exceptions.CommandError,105                          self._test_create_policy,106                          'name', 'description',107                          'action', 'listener',108                          action='REDIRECT_TO_POOL')109    def test_create_reject_policy_with_url(self):110        # lbaas-l7policy-create REJECT policy while specifying url argument.111        self.assertRaises(exceptions.CommandError,112                          self._test_create_policy,113                          'action', 'listener',114                          'redirect-url')115    def test_create_reject_policy_with_pool(self):116        # lbaas-l7policy-create REJECT policy while specifying pool argument.117        self.assertRaises(exceptions.CommandError,118                          self._test_create_policy,119                          'action', 'listener',120                          'redirect-pool')121    def test_create_pool_redirect_policy_with_url(self):122        # lbaas-l7policy-create REDIRECT_TO_POOL policy with url argument.123        self.assertRaises(exceptions.CommandError,124                          self._test_create_policy,125                          'action', 'listener',126                          'redirect-pool', 'redirect-url',127                          action='REDIRECT_TO_POOL')128    def test_create_url_redirect_policy_with_pool(self):129        # lbaas-l7policy-create REDIRECT_TO_URL policy with pool argument.130        self.assertRaises(exceptions.CommandError,131                          self._test_create_policy,132                          'action', 'listener',133                          'redirect-pool', 'redirect-url',134                          action='REDIRECT_TO_URL')135    def test_list_policies(self):136        # lbaas-l7policy-list.137        resources = 'l7policies'138        cmd_resources = 'lbaas_l7policies'139        cmd = l7policy.ListL7Policy(test_cli20.MyApp(sys.stdout), None)140        self._test_list_resources(resources, cmd, True,141                                  cmd_resources=cmd_resources)142    def test_list_policies_pagination(self):143        # lbaas-l7policy-list with pagination.144        resources = 'l7policies'145        cmd_resources = 'lbaas_l7policies'146        cmd = l7policy.ListL7Policy(test_cli20.MyApp(sys.stdout), None)147        self._test_list_resources_with_pagination(148            resources, cmd, cmd_resources=cmd_resources)149    def test_list_policies_sort(self):150        # lbaas-l7policy-list --sort-key id --sort-key asc.151        resources = 'l7policies'152        cmd_resources = 'lbaas_l7policies'153        cmd = l7policy.ListL7Policy(test_cli20.MyApp(sys.stdout), None)154        self._test_list_resources(155            resources, cmd, True, cmd_resources=cmd_resources)156    def test_list_policies_limit(self):157        # lbaas-l7policy-list -P.158        resources = 'l7policies'159        cmd_resources = 'lbaas_l7policies'160        cmd = l7policy.ListL7Policy(test_cli20.MyApp(sys.stdout), None)161        self._test_list_resources(162            resources, cmd, page_size=1000, cmd_resources=cmd_resources)163    def test_show_policy_id(self):164        # lbaas-l7policy-show test_id.165        resource = 'l7policy'166        cmd_resource = 'lbaas_l7policy'167        cmd = l7policy.ShowL7Policy(test_cli20.MyApp(sys.stdout), None)168        args = ['--fields', 'test_id', self.test_id]169        self._test_show_resource(170            resource, cmd, self.test_id, args,171            ['test_id'], cmd_resource=cmd_resource)172    def test_show_policy_id_name(self):173        # lbaas-l7policy-show.174        resource = 'l7policy'175        cmd_resource = 'lbaas_l7policy'176        cmd = l7policy.ShowL7Policy(test_cli20.MyApp(sys.stdout), None)177        args = ['--fields', 'test_id', '--fields', 'name', self.test_id]178        self._test_show_resource(179            resource, cmd, self.test_id, args,180            ['test_id', 'name'], cmd_resource=cmd_resource)181    def test_disable_policy(self):182        # lbaas-l7policy-update test_id --admin-state-up False.183        self._test_update_policy('admin-state-up',184                                 **{'admin-state-up': 'False'})185    def test_update_policy_name_and_description(self):186        # lbaas-l7policy-update test_id --name other --description other_desc.187        self._test_update_policy('name', 'description',188                                 name='name',189                                 description='other desc')190    def test_update_pool_redirect_policy(self):191        # lbaas-l7policy-update test_id --action REDIRECT_TO_POOL192        #    --redirect-pool id.193        self._test_update_policy('action', 'redirect-pool',194                                 **{'action': 'REDIRECT_TO_POOL',195                                    'redirect-pool': 'id'})196    def test_update_url_redirect_policy(self):197        # lbaas-l7policy-update test_id --action REDIRECT_TO_URL198        #    --redirect-url http://other_url.199        self._test_update_policy('action', 'redirect-url',200                                 **{'action': 'REDIRECT_TO_URL',201                                    'redirect-url': 'http://other_url'})202    def test_update_policy_position(self):203        # lbaas-l7policy-update test_id --position 2.204        self._test_update_policy('position',205                                 position=2)206    def test_delete_policy(self):207        # lbaas-l7policy-delete test_id.208        resource = 'l7policy'209        cmd_resource = 'lbaas_l7policy'210        cmd = l7policy.DeleteL7Policy(test_cli20.MyApp(sys.stdout), None)211        test_id = 'test_id'212        args = [test_id]213        self._test_delete_resource(resource, cmd, test_id, args,...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!!
