diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-05-11 13:14:40 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-05-11 13:14:40 +0000 |
commit | 02b2f48f9abeb9cc1d31727946d80954d7635849 (patch) | |
tree | 7fed6fa07f43bba1b3d5084d9059cb8ea0c44f74 | |
parent | 600627791896972f09f364210ade2fec3b680f4e (diff) | |
parent | b1245621da4ef8cccff171e9516f3b7289dda407 (diff) | |
download | python-glanceclient-02b2f48f9abeb9cc1d31727946d80954d7635849.tar.gz |
Merge "Fix missing of debug info after we use session" into stable/mitaka
-rwxr-xr-x | glanceclient/shell.py | 6 | ||||
-rw-r--r-- | glanceclient/tests/unit/test_shell.py | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/glanceclient/shell.py b/glanceclient/shell.py index fba6583..2603aa2 100755 --- a/glanceclient/shell.py +++ b/glanceclient/shell.py @@ -577,6 +577,12 @@ class OpenStackImagesShell(object): if not args.os_password and options.os_password: args.os_password = options.os_password + if args.debug: + # Set up the root logger to debug so that the submodules can + # print debug messages + logging.basicConfig(level=logging.DEBUG) + # for iso8601 < 0.1.11 + logging.getLogger('iso8601').setLevel(logging.WARNING) LOG = logging.getLogger('glanceclient') LOG.addHandler(logging.StreamHandler()) LOG.setLevel(logging.DEBUG if args.debug else logging.INFO) diff --git a/glanceclient/tests/unit/test_shell.py b/glanceclient/tests/unit/test_shell.py index da24e6b..7d0d357 100644 --- a/glanceclient/tests/unit/test_shell.py +++ b/glanceclient/tests/unit/test_shell.py @@ -20,6 +20,7 @@ try: except ImportError: from ordereddict import OrderedDict import hashlib +import logging import os import sys import traceback @@ -550,6 +551,20 @@ class ShellTest(testutils.TestCase): self.assertIn('Command-line interface to the OpenStack Images API', sys.stdout.getvalue()) + @mock.patch('glanceclient.v2.client.Client') + @mock.patch('glanceclient.v1.shell.do_image_list') + @mock.patch('glanceclient.shell.logging.basicConfig') + def test_setup_debug(self, conf, func, v2_client): + cli2 = mock.MagicMock() + v2_client.return_value = cli2 + cli2.http_client.get.return_value = (None, {'versions': []}) + args = '--debug image-list' + glance_shell = openstack_shell.OpenStackImagesShell() + glance_shell.main(args.split()) + glance_logger = logging.getLogger('glanceclient') + self.assertEqual(glance_logger.getEffectiveLevel(), logging.DEBUG) + conf.assert_called_with(level=logging.DEBUG) + class ShellTestWithKeystoneV3Auth(ShellTest): # auth environment to use |