diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-04-16 12:14:59 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-04-16 12:14:59 +0000 |
| commit | 700c0b405720b9590a3ee7e96a2de58b64fe016c (patch) | |
| tree | 9db38539ad79c04d30635170e746e37e97482bc4 | |
| parent | 196474f6f36041ac39e8f9d46acdd2f38f0d4652 (diff) | |
| parent | 4d4e4decc39fe68f3624f92903ed29edd605375e (diff) | |
| download | python-neutronclient-700c0b405720b9590a3ee7e96a2de58b64fe016c.tar.gz | |
Merge "Fix using wrong status code in some tests"
| -rw-r--r-- | neutronclient/tests/unit/bgp/test_cli20_speaker.py | 12 | ||||
| -rw-r--r-- | neutronclient/tests/unit/test_cli20.py | 6 | ||||
| -rw-r--r-- | neutronclient/tests/unit/test_cli20_router.py | 5 | ||||
| -rw-r--r-- | neutronclient/v2_0/client.py | 3 |
4 files changed, 19 insertions, 7 deletions
diff --git a/neutronclient/tests/unit/bgp/test_cli20_speaker.py b/neutronclient/tests/unit/bgp/test_cli20_speaker.py index 63ce5fc..2f6e653 100644 --- a/neutronclient/tests/unit/bgp/test_cli20_speaker.py +++ b/neutronclient/tests/unit/bgp/test_cli20_speaker.py @@ -210,10 +210,14 @@ class CLITestV20BGPSpeakerJSON(test_cli20.CLITestV20Base): body = {'bgp_peer_id': 'peerid'} if action == 'add': retval = {'bgp_peer': 'peerid'} + retval = self.client.serialize(retval) + expected_code = 200 else: retval = None + expected_code = 204 self._test_update_resource_action(resource, cmd, 'myid', - subcmd, args, body, retval) + subcmd, args, body, expected_code, + retval) def test_add_peer_to_bgp_speaker(self): # Add peer to BGP speaker: myid peer_id=peerid @@ -236,10 +240,14 @@ class CLITestV20BGPSpeakerJSON(test_cli20.CLITestV20Base): body = {'network_id': 'netid'} if action == 'add': retval = {'network': 'netid'} + retval = self.client.serialize(retval) + expected_code = 200 else: retval = None + expected_code = 204 self._test_update_resource_action(resource, cmd, 'myid', - subcmd, args, body, retval) + subcmd, args, body, expected_code, + retval) def test_add_network_to_bgp_speaker(self): # Add peer to BGP speaker: myid network_id=netid diff --git a/neutronclient/tests/unit/test_cli20.py b/neutronclient/tests/unit/test_cli20.py index 2a18329..05cc31b 100644 --- a/neutronclient/tests/unit/test_cli20.py +++ b/neutronclient/tests/unit/test_cli20.py @@ -554,7 +554,8 @@ class CLITestV20Base(base.BaseTestCase): self.assertIn(extra_id, _str) def _test_update_resource_action(self, resource, cmd, myid, action, args, - body, retval=None, cmd_resource=None): + body, expected_code=200, retval=None, + cmd_resource=None): self.mox.StubOutWithMock(cmd, "get_client") self.mox.StubOutWithMock(self.client.httpclient, "request") cmd.get_client().MultipleTimes().AndReturn(self.client) @@ -566,7 +567,8 @@ class CLITestV20Base(base.BaseTestCase): end_url(path % path_action, format=self.format), 'PUT', body=MyComparator(body, self.client), headers=mox.ContainsKeyValue( - 'X-Auth-Token', TOKEN)).AndReturn((MyResp(204), retval)) + 'X-Auth-Token', TOKEN)).AndReturn((MyResp(expected_code), + retval)) self.mox.ReplayAll() cmd_parser = cmd.get_parser("update_" + cmd_resource) shell.run_command(cmd, cmd_parser, args) diff --git a/neutronclient/tests/unit/test_cli20_router.py b/neutronclient/tests/unit/test_cli20_router.py index b2d9a70..ba267f7 100644 --- a/neutronclient/tests/unit/test_cli20_router.py +++ b/neutronclient/tests/unit/test_cli20_router.py @@ -303,11 +303,14 @@ class CLITestV20RouterJSON(test_cli20.CLITestV20Base): body = {'subnet_id': 'subnetid'} if action == 'add': retval = {'subnet_id': 'subnetid', 'port_id': 'portid'} + retval = self.client.serialize(retval) + expected_code = 200 else: retval = None + expected_code = 204 self._test_update_resource_action(resource, cmd, 'myid', subcmd, args, - body, retval) + body, expected_code, retval) def test_add_interface_compat(self): # Add interface to router: myid subnetid. diff --git a/neutronclient/v2_0/client.py b/neutronclient/v2_0/client.py index 65df0c8..d4073ae 100644 --- a/neutronclient/v2_0/client.py +++ b/neutronclient/v2_0/client.py @@ -312,8 +312,7 @@ class ClientBase(object): def deserialize(self, data, status_code): """Deserializes a JSON string into a dictionary.""" - # TODO(hichihara): Remove checking 204 in bug 1611167 - if status_code == 204 or not data: + if not data: return data return serializer.Serializer().deserialize( data)['body'] |
