How to use _list_users_with_params method in tempest

Best Python code snippet using tempest_python

test_list_users.py

Source:test_list_users.py Github

copy

Full Screen

...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):...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful