Merge "Fix 'List' command filters do not accept unicode symbols"

This commit is contained in:
Zuul 2018-03-21 18:19:10 +00:00 committed by Gerrit Code Review
commit 66bb56bd86
3 changed files with 29 additions and 7 deletions

View File

@ -180,9 +180,15 @@ class Manager(utils.HookableMixin):
return self.resource_class(self, body)
def _build_query_string(self, search_opts):
q_string = parse.urlencode(
sorted([(k, v) for (k, v) in search_opts.items() if v]))
return "?%s" % q_string if q_string else q_string
query_string = ""
if search_opts:
search_opts = utils.unicode_key_value_to_string(search_opts)
params = sorted(
[(k, v) for (k, v) in search_opts.items() if v])
if params:
query_string = "?%s" % parse.urlencode(params)
return query_string
class ManagerWithFind(Manager):

View File

@ -2096,6 +2096,22 @@ class ShellTest(test_utils.TestCase):
'GET',
'/share-groups/detail?description%7E=fake_description')
def test_share_group_list_filter_by_inexact_unicode_name(self):
for separator in self.separators:
self.run_command('share-group-list --name~' + separator +
u'ффф')
self.assert_called(
'GET',
'/share-groups/detail?name%7E=%D1%84%D1%84%D1%84')
def test_share_group_list_filter_by_inexact_unicode_description(self):
for separator in self.separators:
self.run_command('share-group-list --description~' + separator +
u'ффф')
self.assert_called(
'GET',
'/share-groups/detail?description%7E=%D1%84%D1%84%D1%84')
def test_share_group_show(self):
self.run_command('share-group-show 1234')

View File

@ -4289,13 +4289,13 @@ def do_share_group_create(cs, args):
@cliutils.arg(
'--name',
metavar='<name>',
type=str,
type=six.text_type,
default=None,
help='Filter results by name.')
@cliutils.arg(
'--description',
metavar='<description>',
type=str,
type=six.text_type,
default=None,
help='Filter results by description. '
'Available only for microversion >= 2.36.')
@ -4385,14 +4385,14 @@ def do_share_group_create(cs, args):
@cliutils.arg(
'--name~',
metavar='<name~>',
type=str,
type=six.text_type,
default=None,
help='Filter results matching a share group name pattern. '
'Available only for microversion >= 2.36.')
@cliutils.arg(
'--description~',
metavar='<description~>',
type=str,
type=six.text_type,
default=None,
help='Filter results matching a share group description pattern. '
'Available only for microversion >= 2.36.')