Best Python code snippet using tempest_python
test_oauth_consumers.py
Source:test_oauth_consumers.py  
...28                        self.oauth_consumers_client.delete_consumer,29                        consumer['id'])30        return consumer31    @decorators.idempotent_id('c8307ea6-a86c-47fd-ae7b-5b3b2caca76d')32    def test_create_and_show_consumer(self):33        """Tests to make sure that a consumer with parameters is made"""34        consumer = self._create_consumer()35        # fetch created consumer from client36        fetched_consumer = self.oauth_consumers_client.show_consumer(37            consumer['id'])['consumer']38        # assert that the fetched consumer matches the created one and39        # has all parameters40        for key in ['description', 'id', 'links']:41            self.assertEqual(consumer[key], fetched_consumer[key])42    @decorators.idempotent_id('fdfa1b7f-2a31-4354-b2c7-f6ae20554f93')43    def test_delete_consumer(self):44        """Tests the delete function."""45        consumer = self._create_consumer()46        # fetch consumer from client to confirm it exists47        fetched_consumer = self.oauth_consumers_client.show_consumer(48            consumer['id'])['consumer']49        self.assertEqual(consumer['id'], fetched_consumer['id'])50        # delete existing consumer51        self.oauth_consumers_client.delete_consumer(consumer['id'])52        # check that consumer no longer exists53        self.assertRaises(exceptions.NotFound,54                          self.oauth_consumers_client.show_consumer,55                          consumer['id'])56    @decorators.idempotent_id('080a9b1a-c009-47c0-9979-5305bf72e3dc')57    def test_update_consumer(self):58        """Tests the update functionality"""59        # create a new consumer to update60        consumer = self._create_consumer()61        # create new description62        new_description = data_utils.rand_name('test_update_consumer')63        # update consumer64        self.oauth_consumers_client.update_consumer(consumer['id'],65                                                    new_description)66        # check that the same consumer now has the new description67        updated_consumer = self.oauth_consumers_client.show_consumer(68            consumer['id'])['consumer']69        self.assertEqual(new_description, updated_consumer['description'])70    @decorators.idempotent_id('09ca50de-78f2-4ffb-ac71-f2254036b2b8')71    def test_list_consumers(self):72        """Test for listing consumers"""73        # create two consumers to populate list74        new_consumer_one = self._create_consumer()75        new_consumer_two = self._create_consumer()76        # fetch the list of consumers77        consumer_list = self.oauth_consumers_client \78                            .list_consumers()['consumers']79        # add fetched consumer ids to a list80        id_list = [consumer['id'] for consumer in consumer_list]81        # check if created consumers are in the 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!!
