Merge "Tags and Metadata fields with unicode cannot be correctly displayed" into stable/ocata
This commit is contained in:
commit
0063ebce2f
|
@ -1,3 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# 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
|
||||
|
@ -134,9 +135,9 @@ class TestServersTagsV226(base.ClientTestBase):
|
|||
|
||||
COMPUTE_API_VERSION = "2.26"
|
||||
|
||||
def _boot_server_with_tags(self):
|
||||
def _boot_server_with_tags(self, tags=["t1", "t2"]):
|
||||
uuid = self._create_server().id
|
||||
self.client.servers.set_tags(uuid, ["t1", "t2"])
|
||||
self.client.servers.set_tags(uuid, tags)
|
||||
return uuid
|
||||
|
||||
def test_show(self):
|
||||
|
@ -145,6 +146,20 @@ class TestServersTagsV226(base.ClientTestBase):
|
|||
self.assertEqual('["t1", "t2"]', self._get_value_from_the_table(
|
||||
output, "tags"))
|
||||
|
||||
def test_unicode_tag_correctly_displayed(self):
|
||||
"""Regression test for bug #1669683.
|
||||
|
||||
List and dict fields with unicode cannot be correctly
|
||||
displayed.
|
||||
|
||||
Ensure that once we fix this it doesn't regress.
|
||||
"""
|
||||
# create an instance with chinese tag
|
||||
uuid = self._boot_server_with_tags(tags=["中文标签"])
|
||||
output = self.nova("show %s" % uuid)
|
||||
self.assertEqual('["中文标签"]', self._get_value_from_the_table(
|
||||
output, "tags"))
|
||||
|
||||
def test_list(self):
|
||||
uuid = self._boot_server_with_tags()
|
||||
output = self.nova("server-tag-list %s" % uuid)
|
||||
|
|
|
@ -246,7 +246,7 @@ def print_dict(d, dict_property="Property", dict_value="Value", wrap=0):
|
|||
for k, v in sorted(d.items()):
|
||||
# convert dict to str to check length
|
||||
if isinstance(v, (dict, list)):
|
||||
v = jsonutils.dumps(v)
|
||||
v = jsonutils.dumps(v, ensure_ascii=False)
|
||||
if wrap > 0:
|
||||
v = textwrap.fill(six.text_type(v), wrap)
|
||||
# if value has a newline, add in multiple rows
|
||||
|
|
Loading…
Reference in New Issue