summaryrefslogtreecommitdiff
path: root/tests/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix v2 requests to non-bleeding edge serversLakshmi N Sampath2014-09-121-0/+11
| | | | | | | | | | | | In the case where v2 requests are sent to a server which is not running head of tree which includes the v2 metadef code some 404 cases need to be handled to enable standard requests to complete. This patch aslo improves fetching schemas -- they are now only fetched as needed. Change-Id: I8c871f11b909337bd7df19b77e606772dbc634b2 Closes-bug: #1367326
* Replace old httpclient with requestsAmalaBasha2014-07-101-59/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This review implements blueprint python-request and replaces the old http client implementation in favor of a new one based on python-requests. Major changes: * raw_request and json_request removed since everything is now being handled by the same method "_request" * New methods that match HTTP's methods were added: - get - put - post - head - patch - delete * Content-Type is now being "inferred" based on the data being sent: - if it is file-like object it chunks the request - if it is a python type not instance of basestring then it'll try to serialize it to json - Every other case will keep the incoming content-type and will send the data as is. * Glanceclient's HTTPSConnection implementation will be used if no-compression flag is set to True. Co-Author: Flavio Percoco<flaper87@gmail.com> Change-Id: I09f70eee3e2777f52ce040296015d41649c2586a
* Reuse class Manager from common codeAndrey Kurilin2014-06-121-0/+26
| | | | | | | | | | | | | | Class `Managers` from `glanceclient.common.base` module is similar to class `apiclient:ManagerWithFind` from common code. In this patch: - class glanceclient.common.base:Managers replaced by apiclient:ManagerWithFind - module glanceclient.common.base marked as 'deprecated' Related to bp common-client-library-2 Change-Id: I41da4a9188e97ca2c07b6234fc2ac0a877553d3f
* Add support for image size in v2 api uploadEdward Hope-Morley2014-02-031-1/+4
| | | | | | | | | | | | Some backend stores e.g. RBD, will fail if told to create an image without a valid size (RBD will fail to write to a zero-size image). Here we add support to allow the image size to be provided when doing an upload. The result is that the upload content-length will be set if available either from checking the supplied file object or as provided by user. Closes-Bug: 1220197 Change-Id: Ia1f2ea5680a139750d931591949b3e0058148b4b
* Python3: use six.StringIO rather than StringIO.StringIOYassine Lamgarchal2014-01-101-4/+4
| | | | | | | It’s an alias for StringIO.StringIO in Python 2 and io.StringIO in Python 3. Change-Id: I5316eaffa2d9d2d5679b85a901933ef0fbfcc2f7
* Fix extra new line that break from progress barm.benchchaoui@cloudbau.de2013-11-201-0/+7
| | | | | | | | The new line should be writed to stdout only when there is a progress bar displayed. Change-Id: If0e62cd5a3734ed67d66d285267c101b7caeea77 Closes-Bug: #1253042
* Replace OpenStack LLC with OpenStack FoundationZhiQiang Fan2013-09-201-1/+1
| | | | | Change-Id: I38dcbcf1a6c8efe540fcf5f29e782cb3826e583d Fixes-Bug: #1214176
* Show a pretty progressbar when uploading and downloading an image.mouad benchchaoui2013-08-081-2/+17
| | | | | | | | | | | | Add a new module that contain generic wrapper for file and iterator, which are used to wrap image to upload and the request body iterator in upload and download cases repectively, to show and advance a pretty progress bar when this laters are consumed, The progress bar is triggered by adding a --progress command line argument to commands: image-create, image-download or image-update. Change-Id: I2ba42fd0c58f4fa087adb568ec3f08246cae3759 bug fix: LP#1112309 blueprint: progressbar-when-uploading
* Add test for glanceclient shellsTatyana Leontovich2013-05-171-0/+32
| | | | | | | | | | | | Add unittests for the following modules: * glanceclient.shell * glanceclient.v1.shell * glanceclient.v1.legacy_shell * glanceclient.v2.shell Also add mock library to the tools/test-requires Implements: blueprint glanceclient-shells-unittests Change-Id: I5ec527c5efff3726932d234d7c67e08149643f89
* Decode input and encode outputFlaper Fesp2013-02-131-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently glanceclient doesn't support non-ASCII characters for images names and properties (names and values as well). This patch introduces 2 functions (utils.py) that will help encoding and decoding strings in a more "secure" way. About the ensure_(str|unicode) functions: They both try to use first the encoding used in stdin (or python's default encoding if that's None) and fallback to utf-8 if those encodings fail to decode a given text. About the changes in glanceclient: The major change is that all inputs will be decoded and will kept as such inside the client's functions and will then be encoded before being printed / sent out the client. There are other small changes, all related to encoding to str, around in order to avoid fails during some conversions. i.e: quoting url encoded parameters. Fixes bug: 1061150 Change-Id: I5c3ea93a716edfe284d19f6291d4e36028f91eb2
* Add happy path tests for ResponseBodyIteratorBrian Waldon2012-10-021-1/+9
| | | | Change-Id: I5e971b57a0591752e7fca76d0df78ce139308db5
* Enable client V2 to download imagesLars Gellrich2012-08-091-0/+3
| | | | | | | | | | Added the CLI option image-download to download an image via API V2. Added utility function to save an image. Added common iterator to validate the checksum. Related to bp glance-client-v2 Change-Id: I0247f5a3462142dc5e9f3dc16cbe00c8e3d42f42
* Replace httplib2 with httplib as http driverBrian Waldon2012-07-231-2/+18
| | | | | | | | * This allows us to send truly chunked responses to users * Handle bad connection url schemes with a new InvalidEndpoint exception * Fixes bug 1023240 Change-Id: I34500987f51d4e0c6e1f89ecf93853de3fcbb1c3
* Add pagination to v1 image-listBrian Waldon2012-07-191-4/+1
| | | | | | | | | | | | | | | | * Use recursive generator function to make subsequent requests to the v1 detailed images resource * 'limit' continues to act as the absolute limit of images to return from a list call * 'page_size' indicates how many images to ask for in each subsequent pagination request * Expose --page-size through the cli * Convert v1 images tests to use strict url comparison * Drop strict_url_check from FakeAPI kwargs - now the functionality is always active and tests must directly match fixture urls * Fix bug 1024614 Change-Id: Ifa7874d88360e03b5c8aa95bfb9d5e6dc6dc927e
* Add pagination to v2 image-listBrian Waldon2012-07-131-3/+4
| | | | | | | | | | | | | | | | | * Use a recursive generator function to iterate over the image container. The presence of next links are indicators to continue pagination while their value drives the location of the next page. * A user can pass in --page-size on the command line, or page_size when using the controller directly, to control how many images are requested with each subsequent paginated request. Default page size is 20. * Add a flag (strict_url_check) for the FakeAPI class to control whether it chops off query params when trying to match a request to a fixture. * Related to bp glance-client-v2. Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a12
* Add 'explain' command to v2 that describes schemasBrian Waldon2012-06-071-0/+33
At its core, this is adding the ability to finx a schema through published links and convert it to a usable object. Related to bp glance-client-v2 Change-Id: I7b38ad091c6b0ad80197eb789503cf73989893e5