summaryrefslogtreecommitdiff
path: root/tests/test_utils.py
Commit message (Collapse)AuthorAgeFilesLines
* Move unit tests to standard directoryStuart McLaren2015-04-181-165/+0
| | | | | | | | | | | | | This patch moves the glanceclient unit tests to the standard directory (xxxclient/tests/unit) in preparation for adding functional gate tests 'check-glanceclient-dsvm-functional' in the same vein as existing client tests for other projects, eg: * check-novaclient-dsvm-functional * check-keystoneclient-dsvm-functional * check-neutronclient-dsvm-functional Change-Id: I29d4b9e3a428c851575ee9afde40d6df583456c4
* Unify using six.moves.range rename everywhereErno Kuvaja2015-02-251-0/+2
| | | | | | | | | Mainly to improve consistency, use range() from six.moves renames across glance. Behaves consistently like py2 xrange() and py3 range(). Change-Id: I7c573a3a9775f454b98d25f2a14f8e9f5f4ac432
* Support schema types with non-str valueFlavio Percoco2014-12-101-0/+44
| | | | | | | | | | | | | | | | | Change I75da1e9309e0f7ef8839dea3ec9c99c58edc5d63 introduced some properties' types which are not string. This broke the `schema_args` utility since lists are not hashable and there was no support for such type values. This patch fixes this issue with a very glance specific strategy in which this values are assumed to have a `null` type and another type - string, integer, etc. The fix ignores `null` options and it takes the first non-null type as the valid one. The patch adds support for enum types that accept `None` Closes-bug: #1401032 Change-Id: I250e8912aca262a56c54ac59bb24f917e5d8cfce
* Finalize Python3 supportFrederic Lepied2014-05-201-1/+4
| | | | | | | Set the environment variable PYTHONHASHSEED to 0 to have predictive tests under Python 3. Change-Id: Ia15a9383e0f20bd0e4572e9f9b9772f1704dff86
* Fix the parameter order of assertEqual in glanceclient testEiichi Aikawa2014-02-251-12/+14
| | | | | | | | | On assertEqual, the order of parameters should be (expected, observed). But, some part of glanceclient test were written with invalid order. This patch fixes this problem. Change-Id: I7722fdce766ce3cc5bc9944dc72d7d0af0b09f69 Partially-bug: #1277104
* Python3: use six.StringIO rather than StringIO.StringIOYassine Lamgarchal2014-01-101-5/+5
| | | | | | | It’s an alias for StringIO.StringIO in Python 2 and io.StringIO in Python 3. Change-Id: I5316eaffa2d9d2d5679b85a901933ef0fbfcc2f7
* Get better format for long lines with PrettyTableFei Long Wang2014-01-061-7/+13
| | | | | | | | | | | | | Based on current implement, the cli output format will be bad if the lines are too long. This issue can be fixed by setting 'max_width'. However, there is a bug against it, see https://code.google.com/p/prettytable/source/browse/trunk/CHANGELOG?r=85 line 3. So the requirements.txt is updated as well. docImpact Fixes bug 1251283 Change-Id: I0d4192ad9d10a3d6d47a8319463a5edb57719a68
* Fix and enable gating on H306Dirk Mueller2013-12-161-1/+1
| | | | | | H306 - module imports should be in alphabetical order Change-Id: I1f8fc25b0e6ca23c21c90bda420f42a45141c2e2
* 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-25/+23
| | | | | | | | | | | | 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
* Encode error messages before sending them to stdoutFlaper Fesp2013-07-291-0/+15
| | | | | | | | | | When an error with non-ascii characters is caught by glanceclient, it fails at printing it and exists with a UnicodeEncodedError. This patch encodes errors' messages using strutils before sending them to stdout. Fixes bug: #1200206 Change-Id: I4dabcd76ffb258840bd6a66ad23c030f34960e86
* Replace utils.ensure_(str|unicode) with strutils.safe(decode|encode)Flaper Fesp2013-06-041-33/+0
| | | | | | | | | | | | | | | | Glanceclient implemented both functions before they landed into oslo. Since both functions are already in oslo, it is now possible to pull them in. There's a small difference between glance's implementation and oslo's, that is the later does not convert non-str objects - int, bool - to str before trying to decode / encode them. This patch takes care of that where necessary, more precisely, while encoding headers before doing a new request. Fixes bug: #1172253 Change-Id: I9a0dca31140bae28d8ec6aede515c5bb852b701b
* Improve Python 3.x compatibilityDirk Mueller2013-04-221-2/+2
| | | | | | | | Some mechanical translation of the deprecated except x,y construct. Should work with Python >= 2.6 just fine Change-Id: I394f9956b9e3e3d9f5f1e9ad50c35b13200af2a1
* Allow for prettytable 0.7.x as wellDirk Mueller2013-03-151-0/+43
| | | | | | | Relax requirements to >= 0.6, < 0.8, as 0.7.x seems to work as well. Added testcase to ensure this. Change-Id: I1a1a709e6053451b1256a0d78f8fe8562fb10e62
* Decode input and encode outputFlaper Fesp2013-02-131-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use testtools instead of unittest.Monty Taylor2013-01-021-2/+2
| | | | | | Part of blueprint grizzly-testtools Change-Id: Ie914fd8f59cddb1a480566ec4eff908bfb51921c
* Simplify human-readable size outputBrian Waldon2012-11-191-3/+5
| | | | | | | | * Limit human-readable sizes to a single decimal * Drop trailing zero * Step one suffix further in the case of a size being 1024 Change-Id: I2eb8ac0571d3d08b52f62155912863870573a37c
* Make image sizes more readable for humansChristian Berendt2012-11-191-0/+5
| | | | | | | | | By introducing the parameter --human-readable for several functions (image-list, image-show, image-update, image-create) it's possible to convert the size in bytes to something more readable like 9.309MB or 1.375GB. Change-Id: I4e2654994361dcf330ed6d681dbed73388f159cb
* Enable client V2 to download imagesLars Gellrich2012-08-091-0/+45
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