Best Python code snippet using tempest_python
versions_client.py
Source:versions_client.py
...15from six.moves import urllib16from tempest.api_schema.response.compute.v2_1 import versions as schema17from tempest.common import service_client18class VersionsClient(service_client.ServiceClient):19 def _get_base_version_url(self):20 # NOTE: The URL which is gotten from keystone's catalog contains21 # API version and project-id like "v2/{project-id}", but we need22 # to access the URL which doesn't contain them for getting API23 # versions. For that, here should use raw_request() instead of24 # get().25 endpoint = self.base_url26 url = urllib.parse.urlparse(endpoint)27 return '%s://%s/' % (url.scheme, url.netloc)28 def list_versions(self):29 version_url = self._get_base_version_url()30 resp, body = self.raw_request(version_url, 'GET')31 body = json.loads(body)32 self.validate_response(schema.list_versions, resp, body)33 return service_client.ResponseBody(resp, body)34 def get_version_by_url(self, version_url):35 """Get the version document by url.36 This gets the version document for a url, useful in testing37 the contents of things like /v2/ or /v2.1/ in Nova. That38 controller needs authenticated access, so we have to get39 ourselves a token before making the request.40 """41 # we need a token for this request42 resp, body = self.raw_request(version_url, 'GET',43 {'X-Auth-Token': self.token})...
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!!