summaryrefslogtreecommitdiff
path: root/glanceclient/tests/unit/test_utils.py
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Remove unicode-related Python2-only code"Zuul2023-01-121-7/+1
|\
| * Remove unicode-related Python2-only codeCyril Roelandt2022-11-141-7/+1
| | | | | | | | | | | | | | | | This commit: - removes the old "u" prefix from all strings - removes the unicode_key_value_to_string function Change-Id: I1da347e31e828fd2359f0935a4da47257116d4cb
* | Merge "Boolean options: use strict checking"Zuul2023-01-121-0/+8
|\ \
| * | Boolean options: use strict checkingCyril Roelandt2022-11-141-0/+8
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Boolean options (such as "--protected" for glance md-namespace-update) should accept a limited amount of valid values, rather than assuming an "invalid" value means "False". The following values (no matter the case) will now be interpreted as True: ‘t’,’true’, ‘on’, ‘y’, ‘yes’, or ‘1’. The following values (no matter the case) will now be interpreted as False: ‘f’, ‘false’, ‘off’, ‘n’, ‘no’, or ‘0’. Change-Id: I0e7942045d883ac398bab4a7a85f2b4ac9b1ed8c Closes-Bug: #1607317
* | schema_args: Do not generate option for read-only propertiesCyril Roelandt2022-09-261-1/+8
|/ | | | | | | | | | The schema_args decorator generates command line options based on the properties defined in a schema. This commit makes sure read-only properties are skipped during this process, since trying to modify their value would result in a Glance error. Closes-Bug: #1561828 Change-Id: I7ccc628a23c9ebdaeedcb9e6d43559f497ce9555
* Do not use the six library in the tests.Cyril Roelandt2020-06-151-17/+12
| | | | Change-Id: Ic8a2a736a733e0151ca82f19bfde428dc04cf255
* Use unittest.mock instead of third party mockSean McGinnis2020-04-181-1/+1
| | | | | | | | Now that we no longer support py27, we can use the standard library unittest.mock module instead of the third party mock lib. Change-Id: I446ee142c7a17446372c910f7f2a36d55df18e04 Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* Image show: print human readable string when the virtual size is unknownCyril Roelandt2018-05-311-0/+38
| | | | | | | | | Currently, when the virtual size of an image is not known, "None" is displayed. To a regular user, it feels like a programming error. We try and make things clearer by using a "human readable" string instead. Change-Id: Id7b8799356857d9bc58cc8a3677024fe1a7f4f56 Partial-Bug: #1665037
* Removes unicode 'u' response from "glance image-tag-update"Abijitha Nadagouda2018-02-021-0/+36
| | | | | | | | | | | "glance image-tag-update" command returns unicoded response for lists. Therefore it requires print_list method from util class to handle such case. Added unicode_key_value_to_string() method to remove extra 'u' from lists and dictionaries. This fix is inspired from cinderclient's implementation. Change-Id: I16a04e8d34f7629f72fe389456001ca1db9335ea Closes-bug: #1534046
* Replace assertTrue(isinstance()) with assertIsInstance()Van Hung Pham2017-06-141-1/+1
| | | | | | | | Some of tests use different method of assertTrue(isinstance(A, B)) or assertEqual(type(A), B). The correct way is to use assertIsInstance(A, B) provided by test tools. Change-Id: Ibb5e5f848c5632f7c1895c47b8c1a938f2c746c3
* Add request id to returned objectsRavi Jethani2017-01-201-0/+50
| | | | | | | | | | | | | | | | | | | | | | | Adding two classes RequestIdProxy and GeneratorProxy derived from wrapt.ObjectProxy to wrap objects returned from the API. GeneratorProxy class is used to wrap generator objects returned by cases like images.list() etc. whereas RequestIdProxy class is used to wrap non-generator object cases like images.create() etc. In all cases the returned object will have the same behavior as the wrapped(original) object. However now the returned objects will have an extra property 'request_ids' which is a list of exactly one request id. For generator cases the request_ids property will be an empty list until the underlying generator is invoked at-least once. Co-Authored-By: Abhishek Kekane <abhishek.kekane@nttdata.com> Closes-Bug: #1525259 Blueprint: return-request-id-to-caller Change-Id: If8c0e0843270ff718a37ca2697afeb8da22aa3b1
* v2 - "readOnly" key should be used in schemaszwei2016-02-041-1/+2
| | | | | | | | | | | | | | If it has a value of boolean true, this keyword indicates that the instance property SHOULD NOT be changed, and attempts by a user agent to modify the value of this property are expected to be rejected by a server. The value of this keyword MUST be a boolean. The default value is false. Further link for reference: http://json-schema.org/latest/json-schema-hypermedia.html#anchor15 Closes-Bug: #1521581 Depends-On: I279fba4099667d193609a31259057b897380d6f0 Change-Id: I96717506259c0d28500b8747369c47029b1dd9b6
* Ensure that identity token in header is not an unicode stringVincent Untz2015-11-171-1/+3
| | | | | | | | | | | | | We need all the headers to be safe strings so they can be joined together and not become an unicode string in doing so. This fixes a bug when creating an image with non-ascii characters in the name. This is required for python 2.6 compatibility. Change-Id: I66ebc27edf4ccd8f903399da58705711c372536d Closes-Bug: 1448080
* Merge "Replace exception_to_str with oslo.utils function"Jenkins2015-09-301-18/+0
|\
| * Replace exception_to_str with oslo.utils functionkairat_kushaev2015-09-221-18/+0
| | | | | | | | | | | | | | | | | | The oslo.utils function has exception_to_unicode that can replace glance util function exception_to_str. So we don't to have this exception_to_str function in glance anymore. Change-Id: I332bc55558087920fdd6ae2d822bece5166f5ba6
* | Fix human readable when size is NoneStuart McLaren2015-09-141-0/+1
|/ | | | | | | If an image size is null don't stack trace when listing. Change-Id: Iba18470edbe032d1d01380372d57fa17adef5f7e Closes-bug: 1495632
* check for None value in utils.safe_headerDavid Edery2015-09-081-0/+15
| | | | | | | | | In case that a sensetive header (that should be obscured by its SHA1 hash) is None, the safe_header throws an exception which fails the calling process and by that may harm the functionality. Change-Id: I56944a382fd546eba0a6dd6d6b1cecf83b1dc106 Closes-Bug: #1491311
* Add unicode support for properties values in v2 shellDarja Shakhray2015-08-031-2/+3
| | | | | | This code allows to set unicode values to v2 properties. Change-Id: I5f9c29a3e458808dd95375c7557dfce0c4f09038 Closes-bug: #1475769
* Enable flake8 checksDarja Shakhray2015-07-211-1/+1
| | | | | | | | | | | | This commit enables new flake8 checks: * E265 block comment should start with '# ' * H405 multi line docstring summary not separated with an empty line * E123 closing bracket does not match indentation of opening bracket's line * H238 old style class declaration, use new style (inherit from `object`) * E128 continuation line under-indented for visual indent and makes related changes in the code. Change-Id: Ie993afc930f6b74d7a990bcaa9fc0e9f5ba1585c
* Close iterables at the end of iterationRobert Collins2015-06-111-0/+13
| | | | | | | | | | | This fixes a bug where if iteration is interrupted, we're stuck until the iterable is garbage collected, which can be a very long time (e.g. if the iterable is held in an exception stack frame). Co-authored-by: Stuart McLaren <stuart.mclaren@hp.com> Change-Id: Ibe9990e8c337c117a978b1cd8ec388c4bc6d3b4b Closes-bug: 1461678
* Move unit tests to standard directoryStuart McLaren2015-04-181-0/+165
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