Best Python code snippet using tempest_python
test_roles_negative.py
Source:test_roles_negative.py  
...133        self.assertRaises(lib_exc.NotFound, self.roles_client.assign_user_role,134                          tenant['id'], user['id'], non_existent_role)135    @test.attr(type=['negative'])136    @test.idempotent_id('b2285aaa-9e76-4704-93a9-7a8acd0a6c8f')137    def test_assign_user_role_for_non_existent_tenant(self):138        # Attempt to assign a role on a non existent tenant should fail139        (user, tenant, role) = self._get_role_params()140        non_existent_tenant = str(uuid.uuid4().hex)141        self.assertRaises(lib_exc.NotFound, self.roles_client.assign_user_role,142                          non_existent_tenant, user['id'], role['id'])143    @test.attr(type=['negative'])144    @test.idempotent_id('5c3132cd-c4c8-4402-b5ea-71eb44e97793')145    def test_assign_duplicate_user_role(self):146        # Duplicate user role should not get assigned147        (user, tenant, role) = self._get_role_params()148        self.roles_client.assign_user_role(tenant['id'], user['id'],149                                           role['id'])150        self.assertRaises(lib_exc.Conflict, self.roles_client.assign_user_role,151                          tenant['id'], user['id'], role['id'])...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!!
