py33: unify the input of request to json format
In novaclient.client.HTTPClient.request, json.dumps() process the body of "POST": kwargs['data'] = json.dumps(kwargs['body']) So, in test case, we should pass the same forat for mock.call(). Also, transform the "data" variable to json format. Close-Bug #1234067 Change-Id: I3a0abaa8064b4360cb94b7b205454e26bddef8e4
This commit is contained in:
parent
3d73fb36e7
commit
e5a193ac43
@ -24,6 +24,8 @@ import novaclient.v1_1.client
|
||||
import novaclient.v3.client
|
||||
from novaclient.tests import utils
|
||||
|
||||
import json
|
||||
|
||||
|
||||
class ClientTest(utils.TestCase):
|
||||
|
||||
@ -71,8 +73,16 @@ class ClientTest(utils.TestCase):
|
||||
reauth_headers = {'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'User-Agent': 'python-novaclient'}
|
||||
data = ('{"auth": {"tenantName": "project", "passwordCredentials":'
|
||||
' {"username": "user", "password": "password"}}}')
|
||||
data = {
|
||||
"auth": {
|
||||
"tenantName": "project",
|
||||
"passwordCredentials": {
|
||||
"username": "user",
|
||||
"password": "password"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expected = [mock.call('GET',
|
||||
'http://example.com/servers/detail',
|
||||
timeout=mock.ANY,
|
||||
@ -82,7 +92,7 @@ class ClientTest(utils.TestCase):
|
||||
timeout=mock.ANY,
|
||||
headers=reauth_headers,
|
||||
allow_redirects=mock.ANY,
|
||||
data=data,
|
||||
data=json.dumps(data),
|
||||
verify=mock.ANY)]
|
||||
self.assertEqual(mock_request.call_args_list, expected)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user