Best Python code snippet using tempest_python
test_tokens.py
Source:test_tokens.py
...136 self.addCleanup(137 self.roles_client.delete_role_from_user_on_domain,138 domain_id, alt_user_id, role_id)139 return domain_id140 def _create_group_domain_role_for_alt_user():141 domain_id = self.setup_test_domain()['id']142 role_id = self.setup_test_role()['id']143 # Create a group.144 group_id = self.setup_test_group(domain_id=domain_id)['id']145 # Add the alt user to the group.146 self.groups_client.add_group_user(group_id, alt_user_id)147 self.addCleanup(self.groups_client.delete_group_user,148 group_id, alt_user_id)149 # Create a role association between the group and domain.150 self.roles_client.create_group_role_on_domain(151 domain_id, group_id, role_id)152 self.addCleanup(153 self.roles_client.delete_role_from_group_on_domain,154 domain_id, group_id, role_id)155 return domain_id156 # Add the alt user to 2 random domains and 2 random groups157 # with randomized domains and roles.158 assigned_domain_ids = []159 for _ in range(2):160 domain_id = _create_user_domain_role_for_alt_user()161 assigned_domain_ids.append(domain_id)162 domain_id = _create_group_domain_role_for_alt_user()163 assigned_domain_ids.append(domain_id)164 # Get available domain scopes for the alt user.165 available_domains = self.os_alt.identity_v3_client.list_auth_domains()[166 'domains']167 fetched_domain_ids = [i['id'] for i in available_domains]168 # Verify the expected domain IDs are in the list.169 missing_domain_ids = \170 [p for p in assigned_domain_ids if p not in fetched_domain_ids]171 self.assertEmpty(missing_domain_ids,172 "Failed to find domain_ids %s in fetched list"...
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!!