Best Python code snippet using tempest_python
test_oauth_token_client.py
Source:test_oauth_token_client.py  
...107        fake_auth = fake_auth_provider.FakeAuthProvider()108        self.client = oauth_token_client.OAUTHTokenClient(fake_auth,109                                                          'identity',110                                                          'regionOne')111    def _mock_token_response(self, body):112        temp_response = [key + '=' + value for key, value in body.items()]113        return '&'.join(temp_response)114    def _test_authorize_request_token(self, bytes_body=False):115        self.check_service_client_function(116            self.client.authorize_request_token,117            'tempest.lib.common.rest_client.RestClient.put',118            self.FAKE_AUTHORIZE_REQUEST_TOKEN,119            bytes_body,120            request_token_id=self.FAKE_CREATE_REQUEST_TOKEN['oauth_token'],121            role_ids=['26b860'],122            status=200)123    def test_create_request_token(self):124        mock_resp = self._mock_token_response(self.FAKE_CREATE_REQUEST_TOKEN)125        resp = fake_http.fake_http_response(None, status=201), mock_resp126        self.useFixture(fixtures.MockPatch(127            'tempest.lib.common.rest_client.RestClient.post',128            return_value=resp))129        resp = self.client.create_request_token(130            consumer_key='12345',131            consumer_secret='23456',132            project_id='c8f58432c6f00162f04d3250f')133        self.assertEqual(self.FAKE_CREATE_REQUEST_TOKEN, resp)134    def test_authorize_token_request_with_str_body(self):135        self._test_authorize_request_token()136    def test_authorize_token_request_with_bytes_body(self):137        self._test_authorize_request_token(bytes_body=True)138    def test_create_access_token(self):139        mock_resp = self._mock_token_response(self.FAKE_CREATE_ACCESS_TOKEN)140        req_secret = self.FAKE_CREATE_REQUEST_TOKEN['oauth_token_secret']141        resp = fake_http.fake_http_response(None, status=201), mock_resp142        self.useFixture(fixtures.MockPatch(143            'tempest.lib.common.rest_client.RestClient.post',144            return_value=resp))145        resp = self.client.create_access_token(146            consumer_key='12345',147            consumer_secret='23456',148            request_key=self.FAKE_CREATE_REQUEST_TOKEN['oauth_token'],149            request_secret=req_secret,150            oauth_verifier='8171')151        self.assertEqual(self.FAKE_CREATE_ACCESS_TOKEN, resp)152    def test_get_access_token(self):153        self.check_service_client_function(...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!!
