Merge "Do not assume order of body and tags elements"

This commit is contained in:
Jenkins 2014-09-27 22:42:56 +00:00 committed by Gerrit Code Review
commit cedba17acf
3 changed files with 7 additions and 6 deletions

View File

@ -40,7 +40,7 @@ def get_tags(**kwargs):
tags = ([dict(tag=value, scope=key) tags = ([dict(tag=value, scope=key)
for key, value in kwargs.iteritems()]) for key, value in kwargs.iteritems()])
tags.append({"tag": NEUTRON_VERSION, "scope": "quantum"}) tags.append({"tag": NEUTRON_VERSION, "scope": "quantum"})
return tags return sorted(tags)
def device_id_to_vm_id(device_id, obfuscate=False): def device_id_to_vm_id(device_id, obfuscate=False):

View File

@ -149,7 +149,7 @@ def create_gateway_device(cluster, tenant_id, display_name, neutron_id,
try: try:
return nsxlib.do_request( return nsxlib.do_request(
HTTP_POST, nsxlib._build_uri_path(TRANSPORTNODE_RESOURCE), HTTP_POST, nsxlib._build_uri_path(TRANSPORTNODE_RESOURCE),
jsonutils.dumps(body), cluster=cluster) jsonutils.dumps(body, sort_keys=True), cluster=cluster)
except api_exc.InvalidSecurityCertificate: except api_exc.InvalidSecurityCertificate:
raise nsx_exc.InvalidSecurityCertificate() raise nsx_exc.InvalidSecurityCertificate()
@ -166,7 +166,7 @@ def update_gateway_device(cluster, gateway_id, tenant_id,
HTTP_PUT, HTTP_PUT,
nsxlib._build_uri_path(TRANSPORTNODE_RESOURCE, nsxlib._build_uri_path(TRANSPORTNODE_RESOURCE,
resource_id=gateway_id), resource_id=gateway_id),
jsonutils.dumps(body), cluster=cluster) jsonutils.dumps(body, sort_keys=True), cluster=cluster)
except api_exc.InvalidSecurityCertificate: except api_exc.InvalidSecurityCertificate:
raise nsx_exc.InvalidSecurityCertificate() raise nsx_exc.InvalidSecurityCertificate()

View File

@ -165,6 +165,7 @@ class L2GatewayTestCase(base.NsxlibTestCase):
"type": '%sConnector' % connector_type}], "type": '%sConnector' % connector_type}],
"admin_status_enabled": True "admin_status_enabled": True
} }
body.get("tags").sort()
if client_certificate: if client_certificate:
body["credential"] = { body["credential"] = {
"client_certificate": { "client_certificate": {
@ -191,7 +192,7 @@ class L2GatewayTestCase(base.NsxlibTestCase):
request_mock.assert_called_once_with( request_mock.assert_called_once_with(
"POST", "POST",
"/ws.v1/transport-node", "/ws.v1/transport-node",
jsonutils.dumps(expected_req_body), jsonutils.dumps(expected_req_body, sort_keys=True),
cluster=self.fake_cluster) cluster=self.fake_cluster)
def test_update_gw_device(self): def test_update_gw_device(self):
@ -215,7 +216,7 @@ class L2GatewayTestCase(base.NsxlibTestCase):
request_mock.assert_called_once_with( request_mock.assert_called_once_with(
"PUT", "PUT",
"/ws.v1/transport-node/whatever", "/ws.v1/transport-node/whatever",
jsonutils.dumps(expected_req_body), jsonutils.dumps(expected_req_body, sort_keys=True),
cluster=self.fake_cluster) cluster=self.fake_cluster)
def test_update_gw_device_without_certificate(self): def test_update_gw_device_without_certificate(self):
@ -238,7 +239,7 @@ class L2GatewayTestCase(base.NsxlibTestCase):
request_mock.assert_called_once_with( request_mock.assert_called_once_with(
"PUT", "PUT",
"/ws.v1/transport-node/whatever", "/ws.v1/transport-node/whatever",
jsonutils.dumps(expected_req_body), jsonutils.dumps(expected_req_body, sort_keys=True),
cluster=self.fake_cluster) cluster=self.fake_cluster)
def test_get_gw_device_status(self): def test_get_gw_device_status(self):