Best Python code snippet using tempest_python
test_roles.py
Source:test_roles.py  
...188        roles = self.roles_client.list_group_roles_on_system(189            self.group_body['id'])['roles']190        self.assertEqual(1, len(roles))191        self.assertEqual(self.role['id'], roles[0]['id'])192        self.roles_client.check_role_from_group_on_system_existence(193            self.group_body['id'], self.role['id'])194        self.roles_client.delete_role_from_group_on_system(195            self.group_body['id'], self.role['id'])196    @decorators.idempotent_id('f5654bcc-08c4-4f71-88fe-05d64e06de94')197    def test_list_roles(self):198        """Test listing roles"""199        # Return a list of all roles200        body = self.roles_client.list_roles()['roles']201        found = [role for role in body if role in self.roles]202        self.assertEqual(len(found), len(self.roles))203    def _create_implied_role(self, prior_role_id, implies_role_id,204                             ignore_not_found=False):205        self.roles_client.create_role_inference_rule(206            prior_role_id, implies_role_id)...test_roles_client.py
Source:test_roles_client.py  
...458            domain_id="b344506af7644f6794d9cb316600b020",459            group_id="123",460            role_id="1234",461            status=204)462    def test_check_role_from_group_on_system_existence(self):463        self.check_service_client_function(464            self.client.check_role_from_group_on_system_existence,465            'tempest.lib.common.rest_client.RestClient.head',466            {},467            group_id="123",468            role_id="1234",469            status=204)470    def test_create_role_inference_rule_with_str_body(self):471        self._test_create_role_inference_rule()472    def test_create_role_inference_rule_with_bytes_body(self):473        self._test_create_role_inference_rule(bytes_body=True)474    def test_show_role_inference_rule_with_str_body(self):475        self._test_show_role_inference_rule()476    def test_show_role_inference_rule_with_bytes_body(self):...roles_client.py
Source:roles_client.py  
...206        resp, _ = self.head('domains/%s/groups/%s/roles/%s' %207                            (domain_id, group_id, role_id))208        self.expected_success(204, resp.status)209        return rest_client.ResponseBody(resp)210    def check_role_from_group_on_system_existence(self, group_id, role_id):211        """Check role of a group on the system."""212        resp, body = self.head('system/groups/%s/roles/%s' %213                               (group_id, role_id))214        self.expected_success(204, resp.status)215        return rest_client.ResponseBody(resp)216    def create_role_inference_rule(self, prior_role, implies_role):217        """Create a role inference rule."""218        resp, body = self.put('roles/%s/implies/%s' %219                              (prior_role, implies_role), None)220        self.expected_success(201, resp.status)221        body = json.loads(body)222        return rest_client.ResponseBody(resp, body)223    def show_role_inference_rule(self, prior_role, implies_role):224        """Get a role inference rule."""...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!!
