Merge "Testcase of listing collection shouldn't depend on default order of db query"
This commit is contained in:
commit
415e074573
@ -715,10 +715,8 @@ class TestPortsV2(QuantumDbPluginV2TestCase):
|
|||||||
with contextlib.nested(self.port(), self.port()) as (port1, port2):
|
with contextlib.nested(self.port(), self.port()) as (port1, port2):
|
||||||
req = self.new_list_request('ports', 'json')
|
req = self.new_list_request('ports', 'json')
|
||||||
port_list = self.deserialize('json', req.get_response(self.api))
|
port_list = self.deserialize('json', req.get_response(self.api))
|
||||||
self.assertEqual(len(port_list['ports']), 2)
|
self.assertItemsEqual([p['id'] for p in port_list['ports']],
|
||||||
ids = [p['id'] for p in port_list['ports']]
|
[port1['port']['id'], port2['port']['id']])
|
||||||
self.assertTrue(port1['port']['id'] in ids)
|
|
||||||
self.assertTrue(port2['port']['id'] in ids)
|
|
||||||
|
|
||||||
def test_list_ports_filtered_by_fixed_ip(self):
|
def test_list_ports_filtered_by_fixed_ip(self):
|
||||||
# for this test we need to enable overlapping ips
|
# for this test we need to enable overlapping ips
|
||||||
@ -752,16 +750,14 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||||||
|
|
||||||
def _list_and_test_ports(expected_len, ports, tenant_id=None):
|
def _list_and_test_ports(expected_len, ports, tenant_id=None):
|
||||||
set_context = tenant_id is not None
|
set_context = tenant_id is not None
|
||||||
port_res = self._list_ports('json',
|
res = self._list_ports('json',
|
||||||
200,
|
200,
|
||||||
network['network']['id'],
|
network['network']['id'],
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
set_context=set_context)
|
set_context=set_context)
|
||||||
port_list = self.deserialize('json', port_res)
|
port_list = self.deserialize('json', res)
|
||||||
self.assertEqual(len(port_list['ports']), expected_len)
|
self.assertItemsEqual([p['id'] for p in port_list['ports']],
|
||||||
ids = [p['id'] for p in port_list['ports']]
|
[p['port']['id'] for p in ports])
|
||||||
for port in ports:
|
|
||||||
self.assertIn(port['port']['id'], ids)
|
|
||||||
|
|
||||||
# Admin request - must return both ports
|
# Admin request - must return both ports
|
||||||
_list_and_test_ports(2, [port1, port2])
|
_list_and_test_ports(2, [port1, port2])
|
||||||
@ -1640,15 +1636,13 @@ class TestNetworksV2(QuantumDbPluginV2TestCase):
|
|||||||
self._validate_behavior_on_bulk_failure(res, 'networks')
|
self._validate_behavior_on_bulk_failure(res, 'networks')
|
||||||
|
|
||||||
def test_list_networks(self):
|
def test_list_networks(self):
|
||||||
with self.network(name='net1') as net1:
|
with self.network() as net1:
|
||||||
with self.network(name='net2') as net2:
|
with self.network() as net2:
|
||||||
req = self.new_list_request('networks')
|
req = self.new_list_request('networks')
|
||||||
res = self.deserialize('json', req.get_response(self.api))
|
res = self.deserialize('json', req.get_response(self.api))
|
||||||
|
self.assertItemsEqual([n['id'] for n in res['networks']],
|
||||||
self.assertEquals(res['networks'][0]['name'],
|
[net1['network']['id'],
|
||||||
net1['network']['name'])
|
net2['network']['id']])
|
||||||
self.assertEquals(res['networks'][1]['name'],
|
|
||||||
net2['network']['name'])
|
|
||||||
|
|
||||||
def test_list_networks_with_parameters(self):
|
def test_list_networks_with_parameters(self):
|
||||||
with self.network(name='net1', admin_status_up=False) as net1:
|
with self.network(name='net1', admin_status_up=False) as net1:
|
||||||
@ -2300,18 +2294,15 @@ class TestSubnetsV2(QuantumDbPluginV2TestCase):
|
|||||||
# or just drop 2.6 support ;)
|
# or just drop 2.6 support ;)
|
||||||
with self.network() as network:
|
with self.network() as network:
|
||||||
with self.subnet(network=network, gateway_ip='10.0.0.1',
|
with self.subnet(network=network, gateway_ip='10.0.0.1',
|
||||||
cidr='10.0.0.0/24') as subnet:
|
cidr='10.0.0.0/24') as subnet1:
|
||||||
with self.subnet(network=network, gateway_ip='10.0.1.1',
|
with self.subnet(network=network, gateway_ip='10.0.1.1',
|
||||||
cidr='10.0.1.0/24') as subnet2:
|
cidr='10.0.1.0/24') as subnet2:
|
||||||
req = self.new_list_request('subnets')
|
req = self.new_list_request('subnets')
|
||||||
res = self.deserialize('json',
|
res = self.deserialize('json',
|
||||||
req.get_response(self.api))
|
req.get_response(self.api))
|
||||||
res1 = res['subnets'][0]
|
self.assertItemsEqual([s['id'] for s in res['subnets']],
|
||||||
res2 = res['subnets'][1]
|
[subnet1['subnet']['id'],
|
||||||
self.assertEquals(res1['cidr'],
|
subnet2['subnet']['id']])
|
||||||
subnet['subnet']['cidr'])
|
|
||||||
self.assertEquals(res2['cidr'],
|
|
||||||
subnet2['subnet']['cidr'])
|
|
||||||
|
|
||||||
def test_list_subnets_shared(self):
|
def test_list_subnets_shared(self):
|
||||||
with self.network(shared=True) as network:
|
with self.network(shared=True) as network:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user