Make _build_uri_path output predictable
This is done by ensuring that filters are serialized in their alphabetical order. Tweak tests affected by this. This is done in the context as defined by etherpad: neutron-random-hashseed Partial-bug: #1348818 Change-Id: Ibe79716a340195ca0365f276ef6e3e728f1a94a1
This commit is contained in:
parent
9bc3812687
commit
de1048806b
@ -56,7 +56,10 @@ def _build_uri_path(resource,
|
||||
params.append(relations and "relations=%s" % relations)
|
||||
params.append(types and "types=%s" % types)
|
||||
if filters:
|
||||
params.extend(['%s=%s' % (k, v) for (k, v) in filters.iteritems()])
|
||||
sorted_filters = [
|
||||
'%s=%s' % (k, filters[k]) for k in sorted(filters.keys())
|
||||
]
|
||||
params.extend(sorted_filters)
|
||||
uri_path = "%s/%s" % (URI_PREFIX, res_path)
|
||||
non_empty_params = [x for x in params if x is not None]
|
||||
if non_empty_params:
|
||||
|
@ -281,7 +281,7 @@ class L2GatewayTestCase(base.NsxlibTestCase):
|
||||
"GET",
|
||||
("/ws.v1/transport-node?fields=uuid,tags&"
|
||||
"relations=TransportNodeStatus&"
|
||||
"tag_scope=os_tid&tag=ssc_napoli&"
|
||||
"tag=ssc_napoli&tag_scope=os_tid&"
|
||||
"_page_length=1000&tag_scope=quantum"),
|
||||
cluster=self.fake_cluster)
|
||||
|
||||
|
@ -81,8 +81,8 @@ class LSNTestCase(base.BaseTestCase):
|
||||
self.assertEqual(lsn_id, result)
|
||||
self.mock_request.assert_called_once_with(
|
||||
"GET",
|
||||
("/ws.v1/lservices-node?fields=uuid&tag_scope="
|
||||
"n_network_id&tag=%s" % net_id),
|
||||
("/ws.v1/lservices-node?fields=uuid&tag=%s&"
|
||||
"tag_scope=n_network_id" % net_id),
|
||||
cluster=self.cluster)
|
||||
|
||||
def test_lsn_for_network_get_none(self):
|
||||
@ -179,8 +179,8 @@ class LSNTestCase(base.BaseTestCase):
|
||||
self.assertEqual(result, port_id)
|
||||
self.mock_request.assert_called_once_with(
|
||||
"GET",
|
||||
("/ws.v1/lservices-node/%s/lport?fields=uuid&tag_scope=%s&"
|
||||
"tag=%s" % (lsn_id, filters["tag_scope"], filters["tag"])),
|
||||
("/ws.v1/lservices-node/%s/lport?fields=uuid&tag=%s&"
|
||||
"tag_scope=%s" % (lsn_id, filters["tag"], filters["tag_scope"])),
|
||||
cluster=self.cluster)
|
||||
|
||||
def test_lsn_port_get_with_filters_return_none(self):
|
||||
|
@ -220,7 +220,7 @@ class NsxUtilsTestCase(base.BaseTestCase):
|
||||
filters = {"tag": 'foo', "tag_scope": "scope_foo"}
|
||||
result = nsxlib._build_uri_path('RESOURCE', filters=filters)
|
||||
expected = (
|
||||
"%s/%s?tag_scope=scope_foo&tag=foo" %
|
||||
"%s/%s?tag=foo&tag_scope=scope_foo" %
|
||||
(nsxlib.URI_PREFIX, 'RESOURCE'))
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user