Merge "NSX: Fix fake_api_client to raise NotFound" into stable/icehouse

This commit is contained in:
Jenkins 2014-04-24 03:00:11 +00:00 committed by Gerrit Code Review
commit 3432a67672
2 changed files with 18 additions and 2 deletions

View File

@ -381,6 +381,9 @@ class FakeClient:
res_dict = getattr(self, '_fake_%s_dict' % resource_type)
if parent_uuid == '*':
parent_uuid = None
# NSX raises ResourceNotFound if lswitch doesn't exist and is not *
elif not res_dict and resource_type == self.LSWITCH_LPORT_RESOURCE:
raise api_exc.ResourceNotFound()
def _attr_match(res_uuid):
if not attr_filter:

View File

@ -183,7 +183,7 @@ class LogicalPortsTestCase(base.NsxlibTestCase):
self.assertIsNotNone(lport2)
self.assertEqual(lport['uuid'], lport2['uuid'])
def test_get_port_by_tag_not_found_returns_None(self):
def test_get_port_by_tag_not_found_with_switch_id_raises_not_found(self):
tenant_id = 'pippo'
neutron_port_id = 'whatever'
transport_zones_config = [{'zone_uuid': _uuid(),
@ -191,8 +191,21 @@ class LogicalPortsTestCase(base.NsxlibTestCase):
lswitch = switchlib.create_lswitch(
self.fake_cluster, tenant_id, _uuid(),
'fake-switch', transport_zones_config)
self.assertRaises(exceptions.NotFound,
switchlib.get_port_by_neutron_tag,
self.fake_cluster, lswitch['uuid'],
neutron_port_id)
def test_get_port_by_tag_not_find_wildcard_lswitch_returns_none(self):
tenant_id = 'pippo'
neutron_port_id = 'whatever'
transport_zones_config = [{'zone_uuid': _uuid(),
'transport_type': 'stt'}]
switchlib.create_lswitch(
self.fake_cluster, tenant_id, _uuid(),
'fake-switch', transport_zones_config)
lport = switchlib.get_port_by_neutron_tag(
self.fake_cluster, lswitch['uuid'], neutron_port_id)
self.fake_cluster, '*', neutron_port_id)
self.assertIsNone(lport)
def test_get_port_status(self):