summaryrefslogtreecommitdiff
path: root/glanceclient/tests/unit/test_shell.py
Commit message (Collapse)AuthorAgeFilesLines
* image-download: tests to catch stray outputStuart McLaren2016-06-291-0/+114
| | | | | | | | | | Add unit tests to ensure that any stray output (eg print statements) during image-download cause a test failure. Regression test for bug 1488914. Change-Id: Ic19ba5693d059bf7c283702e7c333672a878a1a1 Partial-bug: 1488914
* Use correct order of arguments to assertEqualzhengyao12016-06-291-2/+2
| | | | | | | | | | | The correct order of arguments to assertEqual that is expected by testtools is (expected, observed). This patch fixes the inverted usage of arguments in some places that have cropped up since the last fix of this bug. Change-Id: If8c0dcb58496bc2fcf4c635f384522a1f7d2b2af Closes-Bug: #1259292
* Remove deprecated construct method from session initkairat_kushaev2016-06-091-6/+6
| | | | | | | | construct method is marked as deprecated and might be deleted in one of future releases. So glanceclient need to be aware of that and initialize sesssion from command line arguments directly. Change-Id: Ie81b62b7e70bb177f178caadc41554ae88e51b05
* Get endpoint if os_image_url is not setNiall Bunting2016-05-121-16/+77
| | | | | | | | | If env['OS_IMAGE_URL'] is not set then None is returned. This is then used ignoring the endpoint_type, service_type and region_name. This patch will use those values if the endpoint is None. Change-Id: I76cc527b05d2be75d3dbc33123a0d71be97fe25c Closes-bug: #1579768
* Merge "Re-enable stacktracing when --debug is used"Jenkins2016-04-181-0/+39
|\
| * Re-enable stacktracing when --debug is usedStuart McLaren2016-04-071-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 1f89beb6098f4f6a8d8c2912392b273bc068b2e3 introduced the behaviour that a stacktrace is printed if an exception is encountered. This helped make the client more supportable: $ glance --debug image-list . . . File "glanceclient/common/http.py", line 337, in get_http_client xxx NameError: global name 'xxx' is not defined global name 'xxx' is not defined The behaviour was lost at some point. This patch re-enables it. Change-Id: I25fc8624797909d606590747f54b9cf649ade079 Closes-bug: 1563830
* | Merge "Fix v2 so that you can see the default help info"Jenkins2016-04-041-3/+8
|\ \
| * | Fix v2 so that you can see the default help infozwei2016-03-301-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | you can see the default help informatiion is v2 subcommand information if input glance command Co-Authored-By: Stuart McLaren <stuart.mclaren@hp.com> Closes-bug: #1563649 Change-Id: I7d227f3e68aa555b2e25848618f76df4872af35d
* | | Fix missing of debug info after we use sessionCao ShuFeng2016-03-281-0/+15
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | After the introduce of this patch set[1], cli user can't get debug info even --debug is passed. With the patch set[1], the request action will be performed in keystoneclient.session.Session. However the default log level of keystoneclient module is WARNING, so user can't get debug info from keystoneclient.session.Session. This change set the root log level to DEBUG when --debug is passed. [1]: https://review.openstack.org/#/c/262220/ Change-Id: I0db0fd7ab07a0d61082b86829a671d8dbc0f2963 Closes-bug: 1551076
* | Ship the default metadata schema in the clientwangxiyuan2016-03-241-0/+14
|/ | | | | | | | | | | | | | | | | | Now the help message of namespace and resource_type are wrong, we could see a <unavailable> error when try to get the help information, such as "glance help md-namespace-create". See the patch[1] to get more information. the patch[1] added image schema, but the metadata schema are needed as well. This patch adds the current metadata schema into client, so that help text can't be rendered when there schema is not available in the system. [1]: https://review.openstack.org/#/c/209536/3 Change-Id: I2ab94d8768114a7e5c475310ba094af653627658 Closes-Bug: #1536430
* Test: use assert_has_calls() insteadChaozhe.Chen2016-02-241-3/+6
| | | | | | | | Some of the assertions in glanceclient test are sequential, we should better use assert_has_calls() instead of assert_any_call(). And assert_has_calls() provides more clear messages in case of failure. Change-Id: Ie45e7c56b1c859916a1f31636c639422f1ffef28
* Merge "Auto-generated squash commit"Jenkins2016-02-121-1/+1
|\
| * Auto-generated squash commitFlavio Percoco2016-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix misspellings Upstream-Change-Id: Ie7ecbe4b33dd0e1ef94b0be85ec3af790cc6fcd7 Correct spelling mistake Change interable to iterable. Upstream-Change-Id: I468a87a3df9ed00ed82f1ba0d6abbbc6944cf613 Change-Id: I4de8426cd19ef0bc7c00fe57f8bc3303d0a4f8a4 Co-Authored-by: venkatamahesh <venkatamaheshkotha@gmail.com> Co-Authored-by: Irina <yuyuesh@cn.ibm.com>
* | Fix client initialization in shell testskairat_kushaev2016-02-011-4/+6
| | | | | | | | | | | | | | | | | | Shell tests initialized glanceclient with force_auth parameter but this parameter doesn't exist at all. The patch fixes this behavior and modifies client mocking to prevent from these errors in future. Change-Id: If4b469cf8da8105204a7f1f6e80ae19b86c7daee
* | Use session when not specified token or endpointDarja Shakhray2016-01-141-22/+10
|/ | | | | | | | | | When no token or endpoint, it creates a session and from there taken the necessary values. This commit proposes to transfer a session in such cases. This will avoid unnecessary actions and some of the problems. Change-Id: Idc874b6c01e915e52904604d59e8e0b460e71621 Partial-bug: #1519546
* Merge "print usage when no argument is specified for python3"Jenkins2015-10-141-0/+14
|\
| * print usage when no argument is specified for python3Zhiqiang Fan2015-10-091-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | When running just 'glance' under python3, we will get the error: ERROR: 'Namespace' object has no attribute 'func' This is because map() is used to decode sys.argv, but under Python3 it returns a map object which is an iterable. Some code later tries to use this in a boolean context and it will always return True, even if it's empty. Change-Id: I2f03e462cb813833b75b9f2de7badd10b10cddff Closes-Bug: #1295356
* | Use the subcomand parsed args instead of the baseFlavio Percoco2015-10-121-9/+27
|/ | | | | | | | | | | | | | | Pass the subcomand's arguments instead of the base ones to the endpoint creation call when quering the `/versions` endpoint. Passing the wrong arguments will end in the auth_requirement not being identified and an error 'Expected Endpoint' will be raised as no endpoint will be gotten from keystone. This patch also removes an unnecessary mock in the test code related to this fix. Depends-On Iefeb9bc123f8c65fecd0cba585ecd3eb349b23a6 Change-Id: I46088130b9175798e3719e43f48dc474fbc8a251 Closes-bug: #1504058
* No auth when token and endpoint are passedFlavio Percoco2015-09-251-0/+19
| | | | | | | | | | | | | The latest change to the auth_required logic introduced a bug were even when the token and endpoint were passed, authentication was being required. This patch fixes that issue and makes sure that authentication is not required when these 2 arguements are present. Closes-bug: #1499540 Change-Id: I4c9c15ba526378970da5461511ed922d42c5a9f9
* Fixes CLI client called without subcommandsErno Kuvaja2015-09-111-0/+7
| | | | | | | | | | | If CLI client is called without any subcommands or arguments it will fail with """'Namespace' object has no attribute 'command'""". This is coming from the getattr which does not have alternate value specified. Closes-Bug: #1494259 Change-Id: I461f0d4a91f3af2224bafc14a88572a8e4a3c051
* Don't make `help` require auth parametersFlavio Percoco2015-09-091-5/+9
| | | | | | | | | | | | | The `help` command was behaving a bit funky. This patch re-orders the code a bit so that the `help` command will be parsed at the very beginning before running other commands and checks. It also allows to get help without downloading/checking schemas and without requiring auth credentials (previously required by the schema operations). Change-Id: Ib7b10d4d80f15e6b75bb8644d7d916bef09413d6 Closes-bug: #1490457
* Consider `--os-token` when using v2Flavio Percoco2015-09-041-21/+31
| | | | | | | | | | | | | The `_cache_schemas` call currently forces authentication even when the `auth_token` and `os_image_url` are passed. Instead of handling forced authentications, let the client use the passed arguments and authenticate only once if needed. This was not caught by the existing tests because the call to `_cache_schemas` was mocked. Change-Id: I93cec9a68cafc0992d14dab38114d03e25f1e5da Closes-bug: #1490462
* Check if v2 is available and fallbackFlavio Percoco2015-09-041-11/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a basic implementation for a fallback mechanism that will use v1 rather than v2 when downloading schema files from glance-api fails. However, this is not sound. If the schemas are cached already, we won't check if v2 is available and fail to fallback. This patch fixes the aforementioned issue by getting the list of available versions from the server only when the API versions was not explicitly specified through the CLI. That is, for all commands that don't pass `--os-image-api-version 2`, we'll check v2's availability and we'll fallback to v1 if it isn't available. This patch also changes how we handle `/versions` calls in the client. The server has been, incorrectly, replying to requests to `/version` with a 300 error, which ended up in the client re-raising such exception. While I think 300 shouldn't raise an exception, I think we should handle that in a spearate patch. Therefore, this patch just avoids raising such exception when `/version` is explicitly called. This fallback behaviour and the check on `/versions` will be removed in future versions of the client. The later depends on this bug[0] being fixed. [0] https://bugs.launchpad.net/glance/+bug/1491350 Closes-bug: #1489381 Change-Id: Ibeba6bc86db2a97b8a2b4bd042248464cd792e5e
* Password should be prompted onceFlavio Percoco2015-09-011-1/+1
| | | | | | | | | | | | | | | | | | | There's a corner case where password may be requested twice. In a fresh environment, when schemas have not be downloaded for v2, the client will ask for a password to download the schemas and then it'll ask for the password again to run the actual command. This happens because we parse the CLI arguments twice to make sure we're parsing them for the right client version. This patch checks if the password is unset in the newly parsed arguments and if it's been set in the previously parsed ones. In this case it keeps the set password. I believe this approach is safer than re-using the already parsed arguements which may have been parsed for a different API version (might happen because we fallback to v1 if v2 is not available). Change-Id: I080253170e3e84a90363e5bb494cf137895fe2e7 Closes-bug: #1488892
* Merge "Use API v2 as default"Jenkins2015-08-131-18/+48
|\
| * Use API v2 as defaultFei Long Wang2015-08-111-18/+48
| | | | | | | | | | | | | | | | | | | | Now we have claimed v2 is the current API version of Glance, we should change the Glance client as well to be consistent with Glance server. DocImpact Change-Id: I09c9e409d149e2d797785591183e06c13229b7f7
* | Ship the default image schema in the clientFlavio Percoco2015-08-121-0/+7
|/ | | | | | | | | | | | | | | | | | Now that we have stable branches for clients, it's easier to keep track of the current default image's schema in Glance and update it respectively. This patch adds the current image schema, including the schema-properties. One good reason to do this is to be able to react when a running Glance instance is not around to be introspected. It's really unfortunate that things like help text can't be rendered when there image schema is not available in the system. We could keep the schema in a json file but rather than shipping data files with glanceclient we can just have it in the python modules. Change-Id: I9b8cc1d18d6717ccf991fb8149ab13c06d653ee4 Closes-bug: #1481729
* Enable flake8 checksDarja Shakhray2015-07-211-2/+2
| | | | | | | | | | | | 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
* Account for dictionary order in test_shell.pyCorey Bryant2015-06-291-5/+12
| | | | | Change-Id: Id15f3d642e8fcbd663f12b32f52b6014e32574a5 Closes-Bug: 1468485
* Improve import related error handlingStuart McLaren2015-05-081-3/+56
| | | | | | | | | | | | | | | | | | | If there was a problem importing a library we would incorrectly raise an unsupported version error: $ glance --os-image-api-version 1 image-list "1" is not a supported API version. Example values are "1" or "2". We should change this to provide information on the failed import, eg: $ glance --os-image-api-version 1 image-list No module named badimport We also now raise the full stacktrace in this case if '--debug' is passed on the command line. Change-Id: I1c687ae6c5da239090b0b7a4a855b3271a9076da Related-bug: 1402632
* Move unit tests to standard directoryStuart McLaren2015-04-181-0/+512
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