From 4b14da181154d5934eba7eac9584f23c39f4a963 Mon Sep 17 00:00:00 2001 From: Akihiro MOTOKI Date: Wed, 28 Aug 2013 18:28:48 +0900 Subject: [PATCH] Make _test_update_resource honor format Closes-Bug: #1217759 Partial-Bug: #1217791 Due to the Related-Bug: #1217791, MyComparator does not work in some cases. We need to use a workaround that serialized body to mocked self.client.httpclient.request. It is already adopted in _test_create_resourse and I borrow it. Change-Id: I746d272bc7ba8542c29e47823f707a761dddb0b1 --- neutronclient/tests/unit/test_cli20.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/neutronclient/tests/unit/test_cli20.py b/neutronclient/tests/unit/test_cli20.py index 886b1146e..66c73c9d1 100644 --- a/neutronclient/tests/unit/test_cli20.py +++ b/neutronclient/tests/unit/test_cli20.py @@ -216,6 +216,8 @@ class CLITestV20Base(testtools.TestCase): resource_plural = neutronV2_0._get_resource_plural(resource, self.client) path = getattr(self.client, resource_plural + "_path") + # Work around for LP #1217791. XML deserializer called from + # MyComparator does not decodes XML string correctly. if self.format == 'json': mox_body = MyComparator(body, self.client) else: @@ -391,11 +393,18 @@ class CLITestV20Base(testtools.TestCase): cmd.get_client().MultipleTimes().AndReturn(self.client) body = {resource: extrafields} path = getattr(self.client, resource + "_path") + self.client.format = self.format + # Work around for LP #1217791. XML deserializer called from + # MyComparator does not decodes XML string correctly. + if self.format == 'json': + mox_body = MyComparator(body, self.client) + else: + mox_body = self.client.serialize(body) self.client.httpclient.request( MyUrlComparator(end_url(path % myid, format=self.format), self.client), 'PUT', - body=MyComparator(body, self.client), + body=mox_body, headers=mox.ContainsKeyValue( 'X-Auth-Token', TOKEN)).AndReturn((MyResp(204), None)) args.extend(['--request-format', self.format])