Best Python code snippet using tempest_python
test_roles.py
Source: test_roles.py
...31 user = self.get_user_by_name(self.data.test_user)32 tenant = self.get_tenant_by_name(self.data.test_tenant)33 role = self.get_role_by_name(self.data.test_role)34 return (user, tenant, role)35 def assert_role_in_role_list(self, role, roles):36 found = False37 for user_role in roles:38 if user_role['id'] == role['id']:39 found = True40 self.assertTrue(found, "assigned role was not in list")41 @attr(type='gate')42 def test_list_roles(self):43 # Return a list of all roles44 resp, body = self.client.list_roles()45 found = [role for role in body if role in self.data.roles]46 self.assertTrue(any(found))47 self.assertEqual(len(found), len(self.data.roles))48 @attr(type='gate')49 def test_role_create_delete(self):50 # Role should be created, verified, and deleted51 role_name = data_utils.rand_name(name='role-test-')52 resp, body = self.client.create_role(role_name)53 self.assertIn('status', resp)54 self.assertTrue(resp['status'].startswith('2'))55 self.assertEqual(role_name, body['name'])56 resp, body = self.client.list_roles()57 found = [role for role in body if role['name'] == role_name]58 self.assertTrue(any(found))59 resp, body = self.client.delete_role(found[0]['id'])60 self.assertIn('status', resp)61 self.assertTrue(resp['status'].startswith('2'))62 resp, body = self.client.list_roles()63 found = [role for role in body if role['name'] == role_name]64 self.assertFalse(any(found))65 @attr(type='gate')66 def test_assign_user_role(self):67 # Assign a role to a user on a tenant68 (user, tenant, role) = self._get_role_params()69 self.client.assign_user_role(tenant['id'], user['id'], role['id'])70 resp, roles = self.client.list_user_roles(tenant['id'], user['id'])71 self.assert_role_in_role_list(role, roles)72 @attr(type='gate')73 def test_remove_user_role(self):74 # Remove a role assigned to a user on a tenant75 (user, tenant, role) = self._get_role_params()76 resp, user_role = self.client.assign_user_role(tenant['id'],77 user['id'], role['id'])78 resp, body = self.client.remove_user_role(tenant['id'], user['id'],79 user_role['id'])80 self.assertEqual(resp['status'], '204')81 @attr(type='gate')82 def test_list_user_roles(self):83 # List roles assigned to a user on tenant84 (user, tenant, role) = self._get_role_params()85 self.client.assign_user_role(tenant['id'], user['id'], role['id'])86 resp, roles = self.client.list_user_roles(tenant['id'], user['id'])87 self.assert_role_in_role_list(role, roles)88class RolesTestXML(RolesTestJSON):...
Check out the latest blogs from LambdaTest on this topic:
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
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!!