From 47236e2cf1d428c6220c20d55026841c3ac6ab88 Mon Sep 17 00:00:00 2001 From: Ghe Rivero Date: Thu, 2 Oct 2014 10:40:11 +0000 Subject: [PATCH] Bump hacking version Current hacking version is incompatible with the one in the global requirements. Match the hacking module version and made the necessary changes to pass the tests. Change-Id: Ie6b13a4ea112084d4c50dc27f97329dfad5777a1 --- ironicclient/client.py | 7 +++---- ironicclient/common/base.py | 13 +++++++------ ironicclient/common/http.py | 1 + ironicclient/common/utils.py | 5 ++--- ironicclient/exc.py | 4 +--- ironicclient/openstack/__init__.py | 16 ---------------- ironicclient/tests/test_http.py | 17 +++++++++-------- ironicclient/tests/utils.py | 5 ++++- ironicclient/tests/v1/test_node.py | 1 + ironicclient/v1/__init__.py | 16 ---------------- ironicclient/v1/node_shell.py | 4 ++-- ironicclient/v1/shell.py | 6 ++++-- test-requirements.txt | 2 +- 13 files changed, 35 insertions(+), 62 deletions(-) diff --git a/ironicclient/client.py b/ironicclient/client.py index d32ed2b77..901d035be 100644 --- a/ironicclient/client.py +++ b/ironicclient/client.py @@ -54,8 +54,7 @@ def _get_endpoint(client, **kwargs): def get_client(api_version, **kwargs): - """Get an authenticated client, based on the credentials - in the keyword args. + """Get an authenticated client, based on the credentials in args. :param api_version: the API version to use. Valid value: '1'. :param kwargs: keyword args containing credentials, either: @@ -94,8 +93,8 @@ def get_client(api_version, **kwargs): else _ksclient.auth_token) ks_kwargs['region_name'] = kwargs.get('os_region_name') - endpoint = kwargs.get('ironic_url') or \ - _get_endpoint(_ksclient, **ks_kwargs) + endpoint = (kwargs.get('ironic_url') or + _get_endpoint(_ksclient, **ks_kwargs)) auth_ref = _ksclient.auth_ref diff --git a/ironicclient/common/base.py b/ironicclient/common/base.py index c724d257d..7be6ff2bc 100644 --- a/ironicclient/common/base.py +++ b/ironicclient/common/base.py @@ -27,7 +27,9 @@ from ironicclient.openstack.common.apiclient import base def getid(obj): - """Abstracts the common pattern of allowing both an object or an + """Wrapper to get object's ID. + + Abstracts the common pattern of allowing both an object or an object's ID (UUID) as a parameter when dealing with relationships. """ try: @@ -37,9 +39,7 @@ def getid(obj): class Manager(object): - """Managers interact with a particular type of API and provide CRUD - operations for them. - """ + """Provides CRUD operations with a particular API.""" resource_class = None def __init__(self, api): @@ -137,8 +137,9 @@ class Manager(object): class Resource(base.Resource): - """A resource represents a particular instance of an object (tenant, user, - etc). This is pretty much just a bag for attributes. + """Represents a particular instance of an object (tenant, user, etc). + + This is pretty much just a bag for attributes. """ def to_dict(self): diff --git a/ironicclient/common/http.py b/ironicclient/common/http.py index 32c9e822c..1bb898d4e 100644 --- a/ironicclient/common/http.py +++ b/ironicclient/common/http.py @@ -239,6 +239,7 @@ class VerifiedHTTPSConnection(six.moves.http_client.HTTPSConnection): def connect(self): """Connect to a host on a given (SSL) port. + If ca_file is pointing somewhere, use it to check Server Certificate. Redefined/copied and extended from httplib.py:1105 (Python 2.6.x). diff --git a/ironicclient/common/utils.py b/ironicclient/common/utils.py index 4022e58b6..b916e060e 100644 --- a/ironicclient/common/utils.py +++ b/ironicclient/common/utils.py @@ -54,9 +54,8 @@ def define_command(subparsers, command, callback, cmd_mapper): def define_commands_from_module(subparsers, command_module, cmd_mapper): - '''Find all methods beginning with 'do_' in a module, and add them - as commands into a subparsers collection. - ''' + """Add 'do_' methods in a module and add as commands into a subparsers.""" + for method_name in (a for a in dir(command_module) if a.startswith('do_')): # Commands should be hypen-separated instead of underscores. command = method_name[3:].replace('_', '-') diff --git a/ironicclient/exc.py b/ironicclient/exc.py index 22bb0621f..c0f33411f 100644 --- a/ironicclient/exc.py +++ b/ironicclient/exc.py @@ -40,9 +40,7 @@ class InvalidAttribute(ClientException): def from_response(response, message=None, traceback=None, method=None, url=None): - """Return an instance of an HttpError based on response from - httplib/requests. - """ + """Return an HttpError instance based on response from httplib/requests.""" error_body = {} if message: diff --git a/ironicclient/openstack/__init__.py b/ironicclient/openstack/__init__.py index 4dfc51bee..e69de29bb 100644 --- a/ironicclient/openstack/__init__.py +++ b/ironicclient/openstack/__init__.py @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2013 Hewlett-Packard Development Company, L.P. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. diff --git a/ironicclient/tests/test_http.py b/ironicclient/tests/test_http.py index a792f434d..df93a48bd 100644 --- a/ironicclient/tests/test_http.py +++ b/ironicclient/tests/test_http.py @@ -16,6 +16,7 @@ # under the License. import json + import six from ironicclient.common import http @@ -68,8 +69,8 @@ class HttpClientTest(utils.BaseTestCase): version=1, status=500) client = http.HTTPClient('http://localhost/') - client.get_connection = \ - lambda *a, **kw: utils.FakeConnection(fake_resp) + client.get_connection = ( + lambda *a, **kw: utils.FakeConnection(fake_resp)) error = self.assertRaises(exc.InternalServerError, client.json_request, @@ -84,8 +85,8 @@ class HttpClientTest(utils.BaseTestCase): version=1, status=500) client = http.HTTPClient('http://localhost/') - client.get_connection = \ - lambda *a, **kw: utils.FakeConnection(fake_resp) + client.get_connection = ( + lambda *a, **kw: utils.FakeConnection(fake_resp)) error = self.assertRaises(exc.InternalServerError, client.json_request, @@ -94,16 +95,16 @@ class HttpClientTest(utils.BaseTestCase): def test_server_exception_msg_and_traceback(self): error_msg = 'another test error' - error_trace = "\"Traceback (most recent call last):\\n\\n " \ - "File \\\"/usr/local/lib/python2.7/..." + error_trace = ("\"Traceback (most recent call last):\\n\\n " + "File \\\"/usr/local/lib/python2.7/...") error_body = self._get_error_body(error_msg, error_trace) fake_resp = utils.FakeResponse({'content-type': 'application/json'}, six.StringIO(error_body), version=1, status=500) client = http.HTTPClient('http://localhost/') - client.get_connection = \ - lambda *a, **kw: utils.FakeConnection(fake_resp) + client.get_connection = ( + lambda *a, **kw: utils.FakeConnection(fake_resp)) error = self.assertRaises(exc.InternalServerError, client.json_request, diff --git a/ironicclient/tests/utils.py b/ironicclient/tests/utils.py index 7c4dacc9f..7deae6344 100644 --- a/ironicclient/tests/utils.py +++ b/ironicclient/tests/utils.py @@ -17,6 +17,7 @@ import copy import datetime + import fixtures import six import testtools @@ -69,7 +70,9 @@ class FakeConnection(object): class FakeResponse(object): def __init__(self, headers, body=None, version=None, status=None, reason=None): - """:param headers: dict representing HTTP response headers + """Fake object to help testing. + + :param headers: dict representing HTTP response headers :param body: file-like object """ self.headers = headers diff --git a/ironicclient/tests/v1/test_node.py b/ironicclient/tests/v1/test_node.py index ea8b17cd6..8d10704da 100644 --- a/ironicclient/tests/v1/test_node.py +++ b/ironicclient/tests/v1/test_node.py @@ -15,6 +15,7 @@ # under the License. import copy + import mock import testtools from testtools.matchers import HasLength diff --git a/ironicclient/v1/__init__.py b/ironicclient/v1/__init__.py index 2f9d7e266..e69de29bb 100644 --- a/ironicclient/v1/__init__.py +++ b/ironicclient/v1/__init__.py @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2013 Red Hat, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. diff --git a/ironicclient/v1/node_shell.py b/ironicclient/v1/node_shell.py index 40ebee9cd..ab32a812b 100644 --- a/ironicclient/v1/node_shell.py +++ b/ironicclient/v1/node_shell.py @@ -216,8 +216,8 @@ def do_node_vendor_passthru(cc, args): metavar='', type=int, help='Maximum number of ports to return per request, ' - '0 for no limit. Default is the maximum number used ' - 'by the Ironic API Service.') + '0 for no limit. Default is the maximum number used ' + 'by the Ironic API Service.') @cliutils.arg( '--marker', metavar='', diff --git a/ironicclient/v1/shell.py b/ironicclient/v1/shell.py index 0fe526f92..40b48a6b1 100644 --- a/ironicclient/v1/shell.py +++ b/ironicclient/v1/shell.py @@ -28,12 +28,14 @@ COMMAND_MODULES = [ def enhance_parser(parser, subparsers, cmd_mapper): - '''Take a basic (nonversioned) parser and enhance it with + """Enhance parser with API version specific options. + + Take a basic (nonversioned) parser and enhance it with commands and options specific for this version of API. :param parser: top level parser :param subparsers: top level parser's subparsers collection where subcommands will go - ''' + """ for command_module in COMMAND_MODULES: utils.define_commands_from_module(subparsers, command_module, cmd_mapper) diff --git a/test-requirements.txt b/test-requirements.txt index 0db11c45f..21a60ac5e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,7 +5,7 @@ Babel>=1.3 coverage>=3.6 discover fixtures>=0.3.14 -hacking>=0.8.0,<0.9 +hacking>=0.9.2,<0.10 mock>=1.0 oslosphinx>=2.2.0 # Apache-2.0 python-subunit>=0.0.18