From 0d601bbf9ba93b0ec1393155a3af29a5e0c8c8c2 Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 2 Oct 2018 11:42:55 +0200 Subject: [PATCH 1/2] Fix #682 --- IM/REST.py | 4 ++-- test/unit/REST.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/IM/REST.py b/IM/REST.py index 1a6720578..742b1fac2 100644 --- a/IM/REST.py +++ b/IM/REST.py @@ -284,7 +284,7 @@ def format_output(res, default_type="text/plain", field_name=None, list_field_na if isinstance(res, list): info = "\n".join(res) else: - info = str(res) + info = "%s" % res content_type = default_type break @@ -299,7 +299,7 @@ def format_output(res, default_type="text/plain", field_name=None, list_field_na if isinstance(res, list): info = "\n".join(res) else: - info = str(res) + info = "%s" % res bottle.response.content_type = default_type return info diff --git a/test/unit/REST.py b/test/unit/REST.py index 0520aa01a..a98181b59 100755 --- a/test/unit/REST.py +++ b/test/unit/REST.py @@ -152,7 +152,7 @@ def test_GetInfrastructureProperty(self, bottle_request, get_infrastructure, Get GetInfrastructureState.return_value = {'state': "running", 'vm_states': {"vm1": "running", "vm2": "running"}} GetInfrastructureRADL.return_value = "radl" - GetInfrastructureContMsg.return_value = "contmsg" + GetInfrastructureContMsg.return_value = "contmsg" inf = MagicMock() get_infrastructure.return_value = inf @@ -778,6 +778,9 @@ def test_format_output(self, get_media_type): info = format_output(["1", "2"]) self.assertEqual(info, '1\n2') + info = format_output(u'contmsg\xe1', field_name="contmsg", default_type="text/plain") + self.assertEqual(info, u'contmsg\xe1') + get_media_type.return_value = ["application/zip"] info = format_output(["1", "2"]) self.assertEqual(info, 'Unsupported Accept Media Types: application/zip') From 552456b6162f4957de6f3a74930239f3681654ab Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 2 Oct 2018 11:46:24 +0200 Subject: [PATCH 2/2] minor change --- test/unit/REST.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/REST.py b/test/unit/REST.py index a98181b59..a6f8ab1db 100755 --- a/test/unit/REST.py +++ b/test/unit/REST.py @@ -152,7 +152,7 @@ def test_GetInfrastructureProperty(self, bottle_request, get_infrastructure, Get GetInfrastructureState.return_value = {'state': "running", 'vm_states': {"vm1": "running", "vm2": "running"}} GetInfrastructureRADL.return_value = "radl" - GetInfrastructureContMsg.return_value = "contmsg" + GetInfrastructureContMsg.return_value = "contmsg" inf = MagicMock() get_infrastructure.return_value = inf