remove unicode prefix from code (2)
In Python 3, unicode prefix is meaningless. This removes unicode prefix from code implementation and unit tests. Change-Id: Ic4534dfb3fb6a2d8f7fcf4859a0eacbc3bd146e4
This commit is contained in:
@@ -41,12 +41,12 @@ def _construct_yaml_str(self, node):
|
||||
return self.construct_scalar(node)
|
||||
|
||||
|
||||
yaml_loader.add_constructor(u'tag:yaml.org,2002:str', _construct_yaml_str)
|
||||
yaml_loader.add_constructor('tag:yaml.org,2002:str', _construct_yaml_str)
|
||||
# Unquoted dates like 2013-05-23 in yaml files get loaded as objects of type
|
||||
# datetime.data which causes problems in API layer when being processed by
|
||||
# openstack.common.jsonutils. Therefore, make unicode string out of timestamps
|
||||
# until jsonutils can handle dates.
|
||||
yaml_loader.add_constructor(u'tag:yaml.org,2002:timestamp',
|
||||
yaml_loader.add_constructor('tag:yaml.org,2002:timestamp',
|
||||
_construct_yaml_str)
|
||||
|
||||
|
||||
|
@@ -282,7 +282,7 @@ class TestResourceSignal(TestResource):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, [])
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.resource_client.signal.assert_called_with(**{
|
||||
'data': {u'message': u'Content'},
|
||||
'data': {'message': 'Content'},
|
||||
'stack_id': 'my_stack',
|
||||
'resource_name': 'my_resource'
|
||||
})
|
||||
@@ -315,7 +315,7 @@ class TestResourceSignal(TestResource):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, [])
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.resource_client.signal.assert_called_with(**{
|
||||
'data': {u'message': u'Content'},
|
||||
'data': {'message': 'Content'},
|
||||
'stack_id': 'my_stack',
|
||||
'resource_name': 'my_resource'
|
||||
})
|
||||
|
@@ -41,7 +41,7 @@ class EventManagerTest(testtools.TestCase):
|
||||
|
||||
def test_list_event_with_unicode_resource_name(self):
|
||||
stack_id = 'teststack',
|
||||
resource_name = u'\u5de5\u4f5c'
|
||||
resource_name = '\u5de5\u4f5c'
|
||||
manager = events.EventManager(None)
|
||||
with mock.patch('heatclient.v1.events.EventManager._resolve_stack_id')\
|
||||
as mock_re:
|
||||
@@ -130,7 +130,7 @@ class EventManagerTest(testtools.TestCase):
|
||||
@mock.patch('heatclient.common.utils.get_response_body')
|
||||
def test_get_event_with_unicode_resource_name(self, mock_utils, mock_re):
|
||||
fields = {'stack_id': 'teststack',
|
||||
'resource_name': u'\u5de5\u4f5c',
|
||||
'resource_name': '\u5de5\u4f5c',
|
||||
'event_id': '1'}
|
||||
|
||||
class FakeAPI(object):
|
||||
|
@@ -141,7 +141,7 @@ abcde
|
||||
format_utils.print_software_deployment_output(ov, out=out,
|
||||
name='deploy_stderr')
|
||||
self.assertEqual(
|
||||
u'''\
|
||||
'''\
|
||||
deploy_stderr: |
|
||||
...
|
||||
2
|
||||
@@ -161,7 +161,7 @@ abcde
|
||||
name='deploy_stderr',
|
||||
long=True)
|
||||
self.assertEqual(
|
||||
u'''\
|
||||
'''\
|
||||
deploy_stderr: |
|
||||
1
|
||||
2
|
||||
|
@@ -94,7 +94,7 @@ class ResourceManagerTest(testtools.TestCase):
|
||||
|
||||
def test_get_with_unicode_resource_name(self):
|
||||
fields = {'stack_id': 'teststack',
|
||||
'resource_name': u'\u5de5\u4f5c'}
|
||||
'resource_name': '\u5de5\u4f5c'}
|
||||
expect = ('GET',
|
||||
'/stacks/teststack/abcd1234/resources'
|
||||
'/%E5%B7%A5%E4%BD%9C')
|
||||
|
@@ -872,7 +872,7 @@ class ShellTestUserPass(ShellBase):
|
||||
"stack_name": "teststack",
|
||||
"stack_status": 'CREATE_COMPLETE',
|
||||
"creation_time": "2012-10-25T01:58:47Z",
|
||||
"tags": [u'tag1', u'tag2']
|
||||
"tags": ['tag1', 'tag2']
|
||||
}}
|
||||
self.mock_request_get('/stacks/teststack/1', resp_dict)
|
||||
|
||||
@@ -996,7 +996,7 @@ class ShellTestUserPass(ShellBase):
|
||||
' "AWSTemplateFormatVersion": "2010-09-09"',
|
||||
' "Outputs": {}',
|
||||
' "Parameters": {}',
|
||||
u' "Description": "test\u2665"',
|
||||
' "Description": "test\u2665"',
|
||||
' "Resources": {}',
|
||||
'}'
|
||||
]
|
||||
@@ -2424,7 +2424,7 @@ class ShellTestUserPass(ShellBase):
|
||||
'output_value',
|
||||
'description',
|
||||
'output2',
|
||||
"[u'output', u'value', u'2']",
|
||||
"['output', 'value', '2']",
|
||||
'test output 2',
|
||||
]
|
||||
for r in required:
|
||||
@@ -2470,7 +2470,7 @@ class ShellTestUserPass(ShellBase):
|
||||
|
||||
self._output_fake_response('output_uni')
|
||||
list_text = self.shell('output-show teststack/1 output_uni')
|
||||
self.assertEqual(u'test\u2665\n', list_text)
|
||||
self.assertEqual('test\u2665\n', list_text)
|
||||
|
||||
def test_output_show_error(self):
|
||||
self.register_keystone_auth_fixture()
|
||||
@@ -3672,7 +3672,7 @@ class ShellTestDeployment(ShellBase):
|
||||
'id': 'abcd'}}
|
||||
|
||||
deploy_data = {'action': 'UPDATE',
|
||||
'config_id': u'abcd',
|
||||
'config_id': 'abcd',
|
||||
'server_id': 'inst01',
|
||||
'status': 'IN_PROGRESS',
|
||||
'tenant_id': 'asdf'}
|
||||
|
@@ -61,9 +61,9 @@ class ShellEnvironmentTest(testtools.TestCase):
|
||||
_, env_dict = template_utils.process_environment_and_files(
|
||||
env_file)
|
||||
self.assertEqual(
|
||||
{u'resource_registry': {u'resources': {
|
||||
u'bar': {u'hooks': u'pre_create',
|
||||
u'restricted_actions': u'replace'}}}},
|
||||
{'resource_registry': {'resources': {
|
||||
'bar': {'hooks': 'pre_create',
|
||||
'restricted_actions': 'replace'}}}},
|
||||
env_dict)
|
||||
mock_url.assert_called_with('file://%s' % env_file)
|
||||
|
||||
@@ -942,22 +942,22 @@ parameters:
|
||||
json.loads(files.get('file:///home/my/dir/spam/egg.yaml')))
|
||||
|
||||
self.assertEqual({
|
||||
u'heat_template_version': u'2013-05-23',
|
||||
u'parameters': {
|
||||
u'param1': {
|
||||
u'type': u'string'
|
||||
'heat_template_version': '2013-05-23',
|
||||
'parameters': {
|
||||
'param1': {
|
||||
'type': 'string'
|
||||
}
|
||||
},
|
||||
u'resources': {
|
||||
u'resource1': {
|
||||
u'type': u'file:///home/my/dir/foo.yaml',
|
||||
u'properties': {u'foo': u'bar'}
|
||||
'resources': {
|
||||
'resource1': {
|
||||
'type': 'file:///home/my/dir/foo.yaml',
|
||||
'properties': {'foo': 'bar'}
|
||||
},
|
||||
u'resource2': {
|
||||
u'type': u'OS::Heat::ResourceGroup',
|
||||
u'properties': {
|
||||
u'resource_def': {
|
||||
u'type': u'file:///home/my/dir/spam/egg.yaml'
|
||||
'resource2': {
|
||||
'type': 'OS::Heat::ResourceGroup',
|
||||
'properties': {
|
||||
'resource_def': {
|
||||
'type': 'file:///home/my/dir/spam/egg.yaml'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1018,13 +1018,13 @@ parameters:
|
||||
json.loads(files.get('file:///home/my/dir/bar.yaml')))
|
||||
|
||||
self.assertEqual({
|
||||
u'heat_template_version': u'2013-05-23',
|
||||
u'resources': {
|
||||
u'foo': {
|
||||
u'type': u'OS::Type1',
|
||||
u'properties': {
|
||||
u'config': {
|
||||
u'get_file': u'file:///home/my/dir/bar.yaml'
|
||||
'heat_template_version': '2013-05-23',
|
||||
'resources': {
|
||||
'foo': {
|
||||
'type': 'OS::Type1',
|
||||
'properties': {
|
||||
'config': {
|
||||
'get_file': 'file:///home/my/dir/bar.yaml'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1032,13 +1032,13 @@ parameters:
|
||||
}, json.loads(files.get('file:///home/my/dir/foo.yaml')))
|
||||
|
||||
self.assertEqual({
|
||||
u'heat_template_version': u'2013-05-23',
|
||||
u'resources': {
|
||||
u'resource1': {
|
||||
u'type': u'OS::Heat::Stack',
|
||||
u'properties': {
|
||||
u'template': {
|
||||
u'get_file': u'file:///home/my/dir/foo.yaml'
|
||||
'heat_template_version': '2013-05-23',
|
||||
'resources': {
|
||||
'resource1': {
|
||||
'type': 'OS::Heat::Stack',
|
||||
'properties': {
|
||||
'template': {
|
||||
'get_file': 'file:///home/my/dir/foo.yaml'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1102,13 +1102,13 @@ parameters:
|
||||
resource_registry:
|
||||
"OS::Thingy": template.yaml
|
||||
'''
|
||||
template_url = u'file:///home/my/dir/template.yaml'
|
||||
foo_url = u'file:///home/my/dir/foo.yaml'
|
||||
egg_url = u'file:///home/my/dir/spam/egg.yaml'
|
||||
ham_url = u'file:///home/my/dir/spam/ham.yaml'
|
||||
one_url = u'file:///home/my/dir/spam/one.yaml'
|
||||
two_url = u'file:///home/my/dir/spam/two.yaml'
|
||||
three_url = u'file:///home/my/dir/spam/three.yaml'
|
||||
template_url = 'file:///home/my/dir/template.yaml'
|
||||
foo_url = 'file:///home/my/dir/foo.yaml'
|
||||
egg_url = 'file:///home/my/dir/spam/egg.yaml'
|
||||
ham_url = 'file:///home/my/dir/spam/ham.yaml'
|
||||
one_url = 'file:///home/my/dir/spam/one.yaml'
|
||||
two_url = 'file:///home/my/dir/spam/two.yaml'
|
||||
three_url = 'file:///home/my/dir/spam/three.yaml'
|
||||
|
||||
def side_effect(args):
|
||||
if env_url == args:
|
||||
@@ -1138,19 +1138,19 @@ parameters:
|
||||
env_dict)
|
||||
|
||||
self.assertEqual({
|
||||
u'heat_template_version': u'2013-05-23',
|
||||
u'parameters': {u'param1': {u'type': u'string'}},
|
||||
u'resources': {
|
||||
u'resource1': {
|
||||
u'properties': {u'foo': u'bar'},
|
||||
u'type': foo_url
|
||||
'heat_template_version': '2013-05-23',
|
||||
'parameters': {'param1': {'type': 'string'}},
|
||||
'resources': {
|
||||
'resource1': {
|
||||
'properties': {'foo': 'bar'},
|
||||
'type': foo_url
|
||||
},
|
||||
u'resource2': {
|
||||
u'type': u'OS::Heat::ResourceGroup',
|
||||
u'properties': {
|
||||
u'resource_def': {
|
||||
u'type': egg_url},
|
||||
u'with': {u'get_file': ham_url}
|
||||
'resource2': {
|
||||
'type': 'OS::Heat::ResourceGroup',
|
||||
'properties': {
|
||||
'resource_def': {
|
||||
'type': egg_url},
|
||||
'with': {'get_file': ham_url}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1159,17 +1159,17 @@ parameters:
|
||||
self.assertEqual(yaml.safe_load(self.foo_template.decode('utf-8')),
|
||||
json.loads(files.get(foo_url)))
|
||||
self.assertEqual({
|
||||
u'heat_template_version': u'2013-05-23',
|
||||
u'parameters': {u'param1': {u'type': u'string'}},
|
||||
u'resources': {
|
||||
u'resource1': {
|
||||
u'properties': {u'foo': u'bar'},
|
||||
u'type': one_url},
|
||||
u'resource2': {
|
||||
u'type': u'OS::Heat::ResourceGroup',
|
||||
u'properties': {
|
||||
u'resource_def': {u'type': two_url},
|
||||
u'with': {u'get_file': three_url}
|
||||
'heat_template_version': '2013-05-23',
|
||||
'parameters': {'param1': {'type': 'string'}},
|
||||
'resources': {
|
||||
'resource1': {
|
||||
'properties': {'foo': 'bar'},
|
||||
'type': one_url},
|
||||
'resource2': {
|
||||
'type': 'OS::Heat::ResourceGroup',
|
||||
'properties': {
|
||||
'resource_def': {'type': two_url},
|
||||
'with': {'get_file': three_url}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -122,21 +122,21 @@ class ShellTest(testtools.TestCase):
|
||||
|
||||
def test_resource_nested_identifier(self):
|
||||
rsrc_info = {'resource_name': 'aresource',
|
||||
'links': [{'href': u'http://foo/name/id/resources/0',
|
||||
'rel': u'self'},
|
||||
{'href': u'http://foo/name/id',
|
||||
'rel': u'stack'},
|
||||
{'href': u'http://foo/n_name/n_id',
|
||||
'rel': u'nested'}]}
|
||||
'links': [{'href': 'http://foo/name/id/resources/0',
|
||||
'rel': 'self'},
|
||||
{'href': 'http://foo/name/id',
|
||||
'rel': 'stack'},
|
||||
{'href': 'http://foo/n_name/n_id',
|
||||
'rel': 'nested'}]}
|
||||
rsrc = hc_res.Resource(manager=None, info=rsrc_info)
|
||||
self.assertEqual('n_name/n_id', utils.resource_nested_identifier(rsrc))
|
||||
|
||||
def test_resource_nested_identifier_none(self):
|
||||
rsrc_info = {'resource_name': 'aresource',
|
||||
'links': [{'href': u'http://foo/name/id/resources/0',
|
||||
'rel': u'self'},
|
||||
{'href': u'http://foo/name/id',
|
||||
'rel': u'stack'}]}
|
||||
'links': [{'href': 'http://foo/name/id/resources/0',
|
||||
'rel': 'self'},
|
||||
{'href': 'http://foo/name/id',
|
||||
'rel': 'stack'}]}
|
||||
rsrc = hc_res.Resource(manager=None, info=rsrc_info)
|
||||
self.assertIsNone(utils.resource_nested_identifier(rsrc))
|
||||
|
||||
@@ -145,7 +145,7 @@ class ShellTest(testtools.TestCase):
|
||||
self.assertEqual('{}', utils.json_formatter({}))
|
||||
self.assertEqual('{\n "foo": "bar"\n}',
|
||||
utils.json_formatter({"foo": "bar"}))
|
||||
self.assertEqual(u'{\n "Uni": "test\u2665"\n}',
|
||||
self.assertEqual('{\n "Uni": "test\u2665"\n}',
|
||||
utils.json_formatter({"Uni": u"test\u2665"}))
|
||||
|
||||
def test_yaml_formatter(self):
|
||||
|
Reference in New Issue
Block a user