Merge "Update requirements and fix pep issues after it"

This commit is contained in:
Jenkins 2014-07-14 10:03:10 +00:00 committed by Gerrit Code Review
commit 627deb7c87
17 changed files with 89 additions and 140 deletions

View File

@ -246,8 +246,10 @@ class Resource(object):
@property
def human_id(self):
"""Subclasses may override this provide a pretty ID which can be used
for bash completion.
"""Returns human-friendly ID if possible.
Subclasses may override this provide a pretty ID which can
be used for bash completion.
"""
if 'name' in self.__dict__ and self.HUMAN_ID:
return strutils.to_slug(self.name)

View File

@ -232,8 +232,7 @@ class HTTPClient(object):
if resp.status_code == 200: # content must always present
try:
self.auth_url = url
self.service_catalog = \
service_catalog.ServiceCatalog(body)
self.service_catalog = service_catalog.ServiceCatalog(body)
if extract_token:
self.auth_token = self.service_catalog.get_token()
@ -264,7 +263,9 @@ class HTTPClient(object):
raise exceptions.from_response(resp, body)
def _fetch_endpoints_from_auth(self, url):
"""We have a token, but don't know the final endpoint for
"""Fetch endpoints from auth.
We have a token, but don't know the final endpoint for
the region. We have to go back to the auth service and
ask again. This request requires an admin-level token
to work. The proxy token supplied could be from a low-level enduser.

View File

@ -214,8 +214,9 @@ def find_resource(manager, name_or_id):
# Volumes does not have name, but display_name
return manager.find(display_name=name_or_id)
except exceptions.NotFound:
msg = "No %s with a name or ID of '%s' exists." % \
(manager.resource_class.__name__.lower(), name_or_id)
msg = ("No %s with a name or ID of '%s' exists." %
(manager.resource_class.__name__.lower(),
name_or_id))
raise exceptions.CommandError(msg)
except exceptions.NoUniqueMatch:
msg = ("Multiple %s matches found for '%s', use an ID to be more"

View File

@ -1,15 +0,0 @@
# Copyright (c) 2013 OpenStack, LLC.
#
# 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.

View File

@ -52,13 +52,13 @@ class RateLimit(object):
self.next_available = next_available
def __eq__(self, other):
return self.uri == other.uri \
and self.regex == other.regex \
and self.value == other.value \
and self.verb == other.verb \
and self.remain == other.remain \
and self.unit == other.unit \
and self.next_available == other.next_available
return (self.uri == other.uri and
self.regex == other.regex and
self.value == other.value and
self.verb == other.verb and
self.remain == other.remain and
self.unit == other.unit and
self.next_available == other.next_available)
def __repr__(self):
return "<RateLimit: method=%s uri=%s>" % (self.method, self.uri)

View File

@ -46,8 +46,7 @@ class ShareSnapshot(base.Resource):
class ShareSnapshotManager(base.ManagerWithFind):
"""Manage :class:`ShareSnapshot` resources.
"""
"""Manage :class:`ShareSnapshot` resources."""
resource_class = ShareSnapshot
def create(self, share, force=False, name=None, description=None):

View File

@ -217,8 +217,9 @@ def do_quota_update(cs, args):
metavar='<user-id>',
help='ID of user to delete quota for.')
def do_quota_delete(cs, args):
"""Delete quota for a tenant/user so their quota will Revert
back to default.
"""Delete quota for a tenant/user.
quota will Revert back to default.
"""
if not args.tenant:
@ -265,7 +266,7 @@ def do_quota_class_update(cs, args):
@utils.service_type('share')
def do_absolute_limits(cs, args):
"""Print a list of absolute limits for a user"""
"""Print a list of absolute limits for a user."""
limits = cs.limits.get().absolute
columns = ['Name', 'Value']
utils.print_list(limits, columns)
@ -273,7 +274,7 @@ def do_absolute_limits(cs, args):
@utils.service_type('share')
def do_rate_limits(cs, args):
"""Print a list of rate limits for a user"""
"""Print a list of rate limits for a user."""
limits = cs.limits.get().rate
columns = ['Verb', 'URI', 'Value', 'Remain', 'Unit', 'Next_Available']
utils.print_list(limits, columns)
@ -770,8 +771,8 @@ def do_share_network_update(cs, args):
'neutron_subnet_id': args.neutron_subnet_id,
'name': args.name,
'description': args.description}
share_network = _find_share_network(cs, args.share_network)\
.update(**values)
share_network = _find_share_network(
cs, args.share_network).update(**values)
info = share_network._info.copy()
utils.print_dict(info)

View File

@ -7,4 +7,4 @@ pycrypto>=2.6
requests>=1.1
simplejson>=2.0.9
Babel>=1.3
six>=1.6.0
six>=1.7.0

View File

@ -1,9 +1,9 @@
hacking>=0.8.0,<0.9
hacking>=0.9.2,<0.10
coverage>=3.6
discover
fixtures>=0.3.14
mock>=1.0
ordereddict
sphinx>=1.2.1,<1.3
sphinx>=1.1.2,!=1.2.0,<1.3
testrepository>=0.0.18
testtools>=0.9.34

View File

@ -1,36 +0,0 @@
# Copyright (c) 2013 OpenStack, LLC.
#
# 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.
#
# from manilaclient import extension
# from manilaclient.v2.contrib import list_extensions
# from tests import utils
# from tests.v1 import fakes
#
#
# extensions = [
# extension.Extension(list_extensions.__name__.split(".")[-1],
# list_extensions),
# ]
# cs = fakes.FakeClient(extensions=extensions)
#
#
# class ListExtensionsTests(utils.TestCase):
# def test_list_extensions(self):
# all_exts = cs.list_extensions.show_all()
# cs.assert_called('GET', '/extensions')
# self.assertTrue(len(all_exts) > 0)
# for r in all_exts:
# self.assertTrue(len(r.summary) > 0)

View File

@ -12,7 +12,6 @@
import manilaclient.client
import manilaclient.v1.client
from tests import utils

View File

@ -170,19 +170,16 @@ class FakeHTTPClient(fakes.FakeHTTPClient):
'extra_specs': {}}]})
def get_types_1(self, **kw):
return (200, {}, {'volume_type': {'id': 1,
'name': 'test-type-1',
'extra_specs': {}}})
return (200, {}, {'volume_type': {
'id': 1, 'name': 'test-type-1', 'extra_specs': {}}})
def get_types_2(self, **kw):
return (200, {}, {'volume_type': {'id': 2,
'name': 'test-type-2',
'extra_specs': {}}})
return (200, {}, {'volume_type': {
'id': 2, 'name': 'test-type-2', 'extra_specs': {}}})
def post_types(self, body, **kw):
return (202, {}, {'volume_type': {'id': 3,
'name': 'test-type-3',
'extra_specs': {}}})
return (202, {}, {'volume_type': {
'id': 3, 'name': 'test-type-3', 'extra_specs': {}}})
def post_types_1_extra_specs(self, body, **kw):
assert list(body) == ['extra_specs']

View File

@ -90,8 +90,8 @@ class ShareNetworkTest(utils.TestCase):
def test_list_with_filters(self):
filters = OrderedDict([('all_tenants', 1), ('status', 'ERROR')])
expected_path = share_networks.RESOURCES_PATH + '/detail' + \
'?all_tenants=1&status=ERROR'
expected_path = ("%s/detail?all_tenants=1&status="
"ERROR" % share_networks.RESOURCES_PATH)
with mock.patch.object(self.manager, '_list',
mock.Mock(return_value=None)):
@ -146,8 +146,8 @@ class ShareNetworkTest(utils.TestCase):
def test_add_security_service_to_share_nw_object(self):
security_service = 'fake security service'
share_nw = self._FakeShareNetwork()
expected_path = (share_networks.RESOURCE_PATH + '/action') % \
share_nw.id
expected_path = ((share_networks.RESOURCE_PATH +
'/action') % share_nw.id)
expected_body = {'add_security_service': {'security_service_id':
security_service}}
@ -177,8 +177,8 @@ class ShareNetworkTest(utils.TestCase):
def test_remove_security_service_from_share_nw_object(self):
security_service = 'fake security service'
share_nw = self._FakeShareNetwork()
expected_path = (share_networks.RESOURCE_PATH + '/action') % \
share_nw.id
expected_path = ((share_networks.RESOURCE_PATH +
'/action') % share_nw.id)
expected_body = {'remove_security_service': {'security_service_id':
security_service}}

View File

@ -17,7 +17,6 @@
from manilaclient import extension
from manilaclient.v1 import share_snapshots
from tests import utils
from tests.v1 import fakes

View File

@ -17,7 +17,6 @@
from manilaclient import extension
from manilaclient.v1 import shares
from tests import utils
from tests.v1 import fakes

View File

@ -47,7 +47,7 @@ class ShellTest(utils.TestCase):
self.shell = shell.OpenStackManilaShell()
#HACK(bcwaldon): replace this when we start using stubs
# HACK(bcwaldon): replace this when we start using stubs
self.old_get_client_class = client.get_client_class
client.get_client_class = lambda *_: fakes.FakeClient
@ -60,7 +60,7 @@ class ShellTest(utils.TestCase):
'clear_callstack'):
self.shell.cs.clear_callstack()
#HACK(bcwaldon): replace this when we start using stubs
# HACK(bcwaldon): replace this when we start using stubs
client.get_client_class = self.old_get_client_class
super(ShellTest, self).tearDown()
@ -296,9 +296,9 @@ class ShellTest(utils.TestCase):
@mock.patch.object(shell.SecretsHelper, 'check_cached_password',
mock.Mock())
def test_os_cache_enabled_keys_saved_password_not_changed(self):
shell.SecretsHelper.tenant_id = \
shell.SecretsHelper.auth_token = \
shell.SecretsHelper.management_url = 'fake'
shell.SecretsHelper.tenant_id = 'fake'
shell.SecretsHelper.auth_token = 'fake'
shell.SecretsHelper.management_url = 'fake'
self.run_command('--os-cache list')
self.assertFalse(shell.SecretsHelper.password.called)
self.assertFalse(fakes.FakeClient.authenticate.called)
@ -309,13 +309,13 @@ class ShellTest(utils.TestCase):
def test_os_cache_enabled_keys_not_saved_with_password(self):
shell.SecretsHelper._validate_string.return_value = True
shell.ManilaKeyring.get_password.return_value = None
shell.SecretsHelper.tenant_id = \
shell.SecretsHelper.auth_token = \
shell.SecretsHelper.management_url = None
shell.SecretsHelper.tenant_id = None
shell.SecretsHelper.auth_token = None
shell.SecretsHelper.management_url = None
self.run_command('--os-cache list')
self.assertFalse(shell.SecretsHelper._prompt_password.called)
shell.SecretsHelper._validate_string.\
assert_called_once_with('password')
shell.SecretsHelper._validate_string.assert_called_once_with(
'password')
@mock.patch.object(shell.SecretsHelper, '_prompt_password', mock.Mock())
@mock.patch.object(shell.ManilaKeyring, 'get_password', mock.Mock())
@ -323,9 +323,9 @@ class ShellTest(utils.TestCase):
shell.ManilaKeyring.get_password.return_value = None
shell.SecretsHelper._prompt_password.return_value = 'password'
self.useFixture(fixtures.EnvironmentVariable('MANILA_PASSWORD', ''))
shell.SecretsHelper.tenant_id = \
shell.SecretsHelper.auth_token = \
shell.SecretsHelper.management_url = None
shell.SecretsHelper.tenant_id = None
shell.SecretsHelper.auth_token = None
shell.SecretsHelper.management_url = None
self.run_command('--os-cache list')
self.assertTrue(shell.SecretsHelper._prompt_password.called)
@ -335,12 +335,12 @@ class ShellTest(utils.TestCase):
def test_os_cache_enabled_keys_reset_cached_password(self):
shell.ManilaKeyring.get_password.return_value = 'old_password'
shell.SecretsHelper._validate_string.return_value = True
shell.SecretsHelper.tenant_id = \
shell.SecretsHelper.auth_token = \
shell.SecretsHelper.management_url = None
shell.SecretsHelper.tenant_id = None
shell.SecretsHelper.auth_token = None
shell.SecretsHelper.management_url = None
self.run_command('--os-cache --os-reset-cache list')
shell.SecretsHelper._validate_string.\
assert_called_once_with('password')
shell.SecretsHelper._validate_string.assert_called_once_with(
'password')
shell.SecretsHelper.reset.assert_called_once_with()
@mock.patch.object(shell.SecretsHelper, '_validate_string', mock.Mock())
@ -348,8 +348,8 @@ class ShellTest(utils.TestCase):
def test_os_cache_disabled_keys_reset_cached_password(self):
shell.SecretsHelper._validate_string.return_value = True
self.run_command('--os-reset-cache list')
shell.SecretsHelper._validate_string.\
assert_called_once_with('password')
shell.SecretsHelper._validate_string.assert_called_once_with(
'password')
shell.SecretsHelper.reset.assert_called_once_with()
@mock.patch.object(fakes.FakeClient, 'authenticate', mock.Mock())
@ -361,9 +361,9 @@ class ShellTest(utils.TestCase):
return 'old_cached_password'
else:
return 'old_cached_token'
shell.SecretsHelper.tenant_id = \
shell.SecretsHelper.auth_token = \
shell.SecretsHelper.management_url = 'fake'
shell.SecretsHelper.tenant_id = 'fake'
shell.SecretsHelper.auth_token = 'fake'
shell.SecretsHelper.management_url = 'fake'
self.run_command('--os-cache list')
fakes.FakeClient.authenticate.assert_called_once_with()
@ -398,9 +398,9 @@ class ShellTest(utils.TestCase):
})
client.get_client_class = lambda *_: client_v1.Client
shell.SecretsHelper.tenant_id = \
shell.SecretsHelper.auth_token = \
shell.SecretsHelper.management_url = 'fake'
shell.SecretsHelper.tenant_id = 'fake'
shell.SecretsHelper.auth_token = 'fake'
shell.SecretsHelper.management_url = 'fake'
requests.request.side_effect = _fake_request
self.run_command('--os-cache list')
@ -450,20 +450,20 @@ class SecretsHelperTestCase(utils.TestCase):
self.assertTrue(self.helper._validate_string('this is a string'))
def test_make_key(self):
expected_key = 'http://111.11.11.11:5000/user/project/region/' \
'publicURL/share/fake/fake'
expected_key = ('http://111.11.11.11:5000/user/project/region/'
'publicURL/share/fake/fake')
self.assertEqual(self.helper._make_key(), expected_key)
def test_make_key_missing_attrs(self):
self.cs.client.service_name = self.cs.client.region_name = None
expected_key = 'http://111.11.11.11:5000/user/project/?/' \
'publicURL/share/?/fake'
expected_key = ('http://111.11.11.11:5000/user/project/?/'
'publicURL/share/?/fake')
self.assertEqual(self.helper._make_key(), expected_key)
def test_save(self):
shell.ManilaKeyring.get_password.return_value = ''
expected_key = 'http://111.11.11.11:5000/user/project/region/' \
'publicURL/share/fake/fake'
expected_key = ('http://111.11.11.11:5000/user/project/region/'
'publicURL/share/fake/fake')
self.helper.save('fake_token', 'fake_url', 'fake_tenant_id')
shell.ManilaKeyring.set_password.assert_called_once_with(
'manilaclient_auth',
@ -500,8 +500,8 @@ class SecretsHelperTestCase(utils.TestCase):
def test_management_url_os_cache_true(self):
self.assertEqual(self.helper.management_url, 'fake_url')
expected_key = 'http://111.11.11.11:5000/user/project/region/' \
'publicURL/share/fake/fake'
expected_key = ('http://111.11.11.11:5000/user/project/region/'
'publicURL/share/fake/fake')
shell.ManilaKeyring.get_password.assert_called_once_with(
'manilaclient_auth', expected_key)
@ -512,10 +512,10 @@ class SecretsHelperTestCase(utils.TestCase):
def test_auth_token_os_cache_true(self):
self.assertEqual(self.helper.auth_token, 'fake_token')
expected_key = 'http://111.11.11.11:5000/user/project/region/' \
'publicURL/share/fake/fake'
shell.ManilaKeyring.get_password. \
assert_called_once_with('manilaclient_auth', expected_key)
expected_key = ('http://111.11.11.11:5000/user/project/region/'
'publicURL/share/fake/fake')
shell.ManilaKeyring.get_password.assert_called_once_with(
'manilaclient_auth', expected_key)
def test_tenant_id_os_cache_false(self):
self.args.os_cache = False
@ -524,10 +524,10 @@ class SecretsHelperTestCase(utils.TestCase):
def test_tenant_id_os_cache_true(self):
self.assertEqual(self.helper.tenant_id, 'fake_tenant_id')
expected_key = 'http://111.11.11.11:5000/user/project/region/' \
'publicURL/share/fake/fake'
shell.ManilaKeyring.get_password. \
assert_called_once_with('manilaclient_auth', expected_key)
expected_key = ('http://111.11.11.11:5000/user/project/region/'
'publicURL/share/fake/fake')
shell.ManilaKeyring.get_password.assert_called_once_with(
'manilaclient_auth', expected_key)
def test_check_cached_password_os_cache_false(self):
self.args.os_cache = False

View File

@ -149,8 +149,8 @@ class Fedora(Distro):
def get_distro():
if os.path.exists('/etc/fedora-release') or \
os.path.exists('/etc/redhat-release'):
if (os.path.exists('/etc/fedora-release') or
os.path.exists('/etc/redhat-release')):
return Fedora()
elif os.path.exists('/etc/debian_version'):
return Debian()
@ -163,8 +163,10 @@ def check_dependencies():
def create_virtualenv(venv=VENV, no_site_packages=True):
"""Creates the virtual environment and installs PIP only into the
virtual environment
"""Creates the virtual environment.
Creates the virtual environment installs PIP only
into the virtual environment.
"""
print('Creating venv...', end=' ')
if no_site_packages: