Best Python code snippet using tempest_python
test_list_users.py
Source: test_list_users.py
...15from tempest.api.identity import base16from tempest.common.utils import data_utils17from tempest import test18class UsersV3TestJSON(base.BaseIdentityV3AdminTest):19 def _list_users_with_params(self, params, key, expected, not_expected):20 # Helper method to list users filtered with params and21 # assert the response based on expected and not_expected22 # expected: user expected in the list response23 # not_expected: user, which should not be present in list response24 body = self.client.list_users(params)['users']25 self.assertIn(expected[key], map(lambda x: x[key], body))26 self.assertNotIn(not_expected[key],27 map(lambda x: x[key], body))28 @classmethod29 def resource_setup(cls):30 super(UsersV3TestJSON, cls).resource_setup()31 alt_user = data_utils.rand_name('test_user')32 alt_password = data_utils.rand_password()33 cls.alt_email = alt_user + '@testmail.tm'34 cls.data.setup_test_domain()35 # Create user with Domain36 u1_name = data_utils.rand_name('test_user')37 cls.domain_enabled_user = cls.client.create_user(38 u1_name, password=alt_password,39 email=cls.alt_email, domain_id=cls.data.domain['id'])['user']40 cls.data.v3_users.append(cls.domain_enabled_user)41 # Create default not enabled user42 u2_name = data_utils.rand_name('test_user')43 cls.non_domain_enabled_user = cls.client.create_user(44 u2_name, password=alt_password,45 email=cls.alt_email, enabled=False)['user']46 cls.data.v3_users.append(cls.non_domain_enabled_user)47 @test.idempotent_id('08f9aabb-dcfe-41d0-8172-82b5fa0bd73d')48 def test_list_user_domains(self):49 # List users with domain50 params = {'domain_id': self.data.domain['id']}51 self._list_users_with_params(params, 'domain_id',52 self.domain_enabled_user,53 self.non_domain_enabled_user)54 @test.idempotent_id('bff8bf2f-9408-4ef5-b63a-753c8c2124eb')55 def test_list_users_with_not_enabled(self):56 # List the users with not enabled57 params = {'enabled': False}58 self._list_users_with_params(params, 'enabled',59 self.non_domain_enabled_user,60 self.domain_enabled_user)61 @test.idempotent_id('c285bb37-7325-4c02-bff3-3da5d946d683')62 def test_list_users_with_name(self):63 # List users with name64 params = {'name': self.domain_enabled_user['name']}65 self._list_users_with_params(params, 'name',66 self.domain_enabled_user,67 self.non_domain_enabled_user)68 @test.idempotent_id('b30d4651-a2ea-4666-8551-0c0e49692635')69 def test_list_users(self):70 # List users71 body = self.client.list_users()['users']72 fetched_ids = [u['id'] for u in body]73 missing_users = [u['id'] for u in self.data.v3_users74 if u['id'] not in fetched_ids]75 self.assertEqual(0, len(missing_users),76 "Failed to find user %s in fetched list" %77 ', '.join(m_user for m_user in missing_users))78 @test.idempotent_id('b4baa3ae-ac00-4b4e-9e27-80deaad7771f')79 def test_get_user(self):...
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!!