Best Python code snippet using tempest_python
images_client.py
Source:images_client.py  
...29                                  headers=headers, body=data, chunked=True)30        self._error_checker(resp, body)31        body = json.loads(body)32        return rest_client.ResponseBody(resp, body)33    def _update_with_data(self, image_id, headers, data):34        # We are going to do chunked transfert, so split the input data35        # info fixed-sized chunks.36        headers['Content-Type'] = 'application/octet-stream'37        data = iter(functools.partial(data.read, CHUNKSIZE), b'')38        url = 'images/%s' % image_id39        resp, body = self.request('PUT', url, headers=headers,40                                  body=data, chunked=True)41        self._error_checker(resp, body)42        body = json.loads(body)43        return rest_client.ResponseBody(resp, body)44    @property45    def http(self):46        if self._http is None:47            self._http = self._get_http()48        return self._http49    def create_image(self, data=None, headers=None):50        """Create an image.51        For a full list of available parameters, please refer to the official52        API reference:53        http://developer.openstack.org/api-ref-image-v1.html#createImage-v154        """55        if headers is None:56            headers = {}57        if data is not None:58            return self._create_with_data(headers, data)59        resp, body = self.post('images', None, headers)60        self.expected_success(201, resp.status)61        body = json.loads(body)62        return rest_client.ResponseBody(resp, body)63    def update_image(self, image_id, data=None, headers=None):64        """Update an image.65        For a full list of available parameters, please refer to the official66        API reference:67        http://developer.openstack.org/api-ref-image-v1.html#updateImage-v168        """69        if headers is None:70            headers = {}71        if data is not None:72            return self._update_with_data(image_id, headers, data)73        url = 'images/%s' % image_id74        resp, body = self.put(url, None, headers)75        self.expected_success(200, resp.status)76        body = json.loads(body)77        return rest_client.ResponseBody(resp, body)78    def delete_image(self, image_id):79        url = 'images/%s' % image_id80        resp, body = self.delete(url)81        self.expected_success(200, resp.status)82        return rest_client.ResponseBody(resp, body)83    def list_images(self, detail=False, **kwargs):84        """Return a list of all images filtered by input parameters.85        For a full list of available parameters, please refer to the official86        API reference:...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!!
