Merge "Utilizes assertIn"

This commit is contained in:
Jenkins 2013-10-09 17:23:09 +00:00 committed by Gerrit Code Review
commit 468cfe722e
8 changed files with 23 additions and 23 deletions

View File

@ -44,7 +44,7 @@ class PortBindingsTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
self.HAS_PORT_FILTER) self.HAS_PORT_FILTER)
def _check_response_no_portbindings(self, port): def _check_response_no_portbindings(self, port):
self.assertTrue('status' in port) self.assertIn('status', port)
self.assertNotIn(portbindings.VIF_TYPE, port) self.assertNotIn(portbindings.VIF_TYPE, port)
self.assertNotIn(portbindings.CAPABILITIES, port) self.assertNotIn(portbindings.CAPABILITIES, port)

View File

@ -258,7 +258,7 @@ class RouterDBTestCase(test_l3_plugin.L3NatDBIntTestCase):
r1_id = r1['router']['id'] r1_id = r1['router']['id']
body = self._router_interface_action('add', r_id, s_id, body = self._router_interface_action('add', r_id, s_id,
None) None)
self.assertTrue('port_id' in body) self.assertIn('port_id', body)
r_port_id = body['port_id'] r_port_id = body['port_id']
body = self._show('ports', r_port_id) body = self._show('ports', r_port_id)
self.assertEqual(body['port']['device_id'], r_id) self.assertEqual(body['port']['device_id'], r_id)
@ -267,7 +267,7 @@ class RouterDBTestCase(test_l3_plugin.L3NatDBIntTestCase):
s1_id = s1['subnet']['id'] s1_id = s1['subnet']['id']
body = self._router_interface_action('add', r1_id, body = self._router_interface_action('add', r1_id,
s1_id, None) s1_id, None)
self.assertTrue('port_id' in body) self.assertIn('port_id', body)
r1_port_id = body['port_id'] r1_port_id = body['port_id']
body = self._show('ports', r1_port_id) body = self._show('ports', r1_port_id)
self.assertEqual(body['port']['device_id'], r1_id) self.assertEqual(body['port']['device_id'], r1_id)

View File

@ -230,7 +230,7 @@ class TestNecAgent(TestNecAgentBase):
dummy_vif = ovs_lib.VifPort('port1', '1', 'id-1', 'mac-1', None) dummy_vif = ovs_lib.VifPort('port1', '1', 'id-1', 'mac-1', None)
self.state_rpc_api.assert_called_once_with('q-plugin') self.state_rpc_api.assert_called_once_with('q-plugin')
self.assertTrue('start_flag' in self.agent.agent_state) self.assertIn('start_flag', self.agent.agent_state)
self._check_report_state([], 0, fail_mode, first=True) self._check_report_state([], 0, fail_mode, first=True)
self._check_report_state([dummy_vif] * 2, 2, fail_mode) self._check_report_state([dummy_vif] * 2, 2, fail_mode)

View File

@ -112,7 +112,7 @@ class NetworkGatewayExtensionTestCase(base.BaseTestCase):
instance.create_network_gateway.assert_called_with( instance.create_network_gateway.assert_called_with(
mock.ANY, network_gateway=data) mock.ANY, network_gateway=data)
self.assertEqual(res.status_int, exc.HTTPCreated.code) self.assertEqual(res.status_int, exc.HTTPCreated.code)
self.assertTrue(self._resource in res.json) self.assertIn(self._resource, res.json)
nw_gw = res.json[self._resource] nw_gw = res.json[self._resource]
self.assertEqual(nw_gw['id'], nw_gw_id) self.assertEqual(nw_gw['id'], nw_gw_id)
@ -152,7 +152,7 @@ class NetworkGatewayExtensionTestCase(base.BaseTestCase):
instance.update_network_gateway.assert_called_with( instance.update_network_gateway.assert_called_with(
mock.ANY, nw_gw_id, network_gateway=data) mock.ANY, nw_gw_id, network_gateway=data)
self.assertEqual(res.status_int, exc.HTTPOk.code) self.assertEqual(res.status_int, exc.HTTPOk.code)
self.assertTrue(self._resource in res.json) self.assertIn(self._resource, res.json)
nw_gw = res.json[self._resource] nw_gw = res.json[self._resource]
self.assertEqual(nw_gw['id'], nw_gw_id) self.assertEqual(nw_gw['id'], nw_gw_id)
self.assertEqual(nw_gw['name'], nw_gw_name) self.assertEqual(nw_gw['name'], nw_gw_name)
@ -310,11 +310,11 @@ class NetworkGatewayDbTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
net['network']['id'], net['network']['id'],
segmentation_type, segmentation_type,
segmentation_id) segmentation_id)
self.assertTrue('connection_info' in body) self.assertIn('connection_info', body)
connection_info = body['connection_info'] connection_info = body['connection_info']
for attr in ('network_id', 'port_id', for attr in ('network_id', 'port_id',
'network_gateway_id'): 'network_gateway_id'):
self.assertTrue(attr in connection_info) self.assertIn(attr, connection_info)
# fetch port and confirm device_id # fetch port and confirm device_id
gw_port_id = connection_info['port_id'] gw_port_id = connection_info['port_id']
port_body = self._show('ports', gw_port_id) port_body = self._show('ports', gw_port_id)

View File

@ -301,7 +301,7 @@ class TunnelTest(base.BaseTestCase):
a.available_local_vlans = set() a.available_local_vlans = set()
a.local_vlan_map[NET_UUID] = LVM a.local_vlan_map[NET_UUID] = LVM
a.reclaim_local_vlan(NET_UUID) a.reclaim_local_vlan(NET_UUID)
self.assertTrue(LVM.vlan in a.available_local_vlans) self.assertIn(LVM.vlan, a.available_local_vlans)
self.mox.VerifyAll() self.mox.VerifyAll()
def test_reclaim_local_vlan_flat(self): def test_reclaim_local_vlan_flat(self):
@ -324,7 +324,7 @@ class TunnelTest(base.BaseTestCase):
a.available_local_vlans = set() a.available_local_vlans = set()
a.local_vlan_map[NET_UUID] = LVM_FLAT a.local_vlan_map[NET_UUID] = LVM_FLAT
a.reclaim_local_vlan(NET_UUID) a.reclaim_local_vlan(NET_UUID)
self.assertTrue(LVM_FLAT.vlan in a.available_local_vlans) self.assertIn(LVM_FLAT.vlan, a.available_local_vlans)
self.mox.VerifyAll() self.mox.VerifyAll()
def test_reclaim_local_vlan_vlan(self): def test_reclaim_local_vlan_vlan(self):
@ -347,7 +347,7 @@ class TunnelTest(base.BaseTestCase):
a.available_local_vlans = set() a.available_local_vlans = set()
a.local_vlan_map[NET_UUID] = LVM_VLAN a.local_vlan_map[NET_UUID] = LVM_VLAN
a.reclaim_local_vlan(NET_UUID) a.reclaim_local_vlan(NET_UUID)
self.assertTrue(LVM_VLAN.vlan in a.available_local_vlans) self.assertIn(LVM_VLAN.vlan, a.available_local_vlans)
self.mox.VerifyAll() self.mox.VerifyAll()
def test_port_bound(self): def test_port_bound(self):

View File

@ -788,7 +788,7 @@ class TestPortsV2(NeutronDbPluginV2TestCase):
with self.port(name='myname') as port: with self.port(name='myname') as port:
for k, v in keys: for k, v in keys:
self.assertEqual(port['port'][k], v) self.assertEqual(port['port'][k], v)
self.assertTrue('mac_address' in port['port']) self.assertIn('mac_address', port['port'])
ips = port['port']['fixed_ips'] ips = port['port']['fixed_ips']
self.assertEqual(len(ips), 1) self.assertEqual(len(ips), 1)
self.assertEqual(ips[0]['ip_address'], '10.0.0.2') self.assertEqual(ips[0]['ip_address'], '10.0.0.2')
@ -827,7 +827,7 @@ class TestPortsV2(NeutronDbPluginV2TestCase):
port = self.deserialize(self.fmt, port_res) port = self.deserialize(self.fmt, port_res)
for k, v in keys: for k, v in keys:
self.assertEqual(port['port'][k], v) self.assertEqual(port['port'][k], v)
self.assertTrue('mac_address' in port['port']) self.assertIn('mac_address', port['port'])
self._delete('ports', port['port']['id']) self._delete('ports', port['port']['id'])
def test_create_port_public_network_with_ip(self): def test_create_port_public_network_with_ip(self):
@ -845,7 +845,7 @@ class TestPortsV2(NeutronDbPluginV2TestCase):
port = self.deserialize(self.fmt, port_res) port = self.deserialize(self.fmt, port_res)
for k, v in keys: for k, v in keys:
self.assertEqual(port['port'][k], v) self.assertEqual(port['port'][k], v)
self.assertTrue('mac_address' in port['port']) self.assertIn('mac_address', port['port'])
self._delete('ports', port['port']['id']) self._delete('ports', port['port']['id'])
def test_create_ports_bulk_native(self): def test_create_ports_bulk_native(self):

View File

@ -115,7 +115,7 @@ class ResourceExtensionTest(base.BaseTestCase):
# Shouldn't be reached # Shouldn't be reached
self.assertTrue(False) self.assertTrue(False)
except webtest.AppError as e: except webtest.AppError as e:
self.assertTrue('501' in e.message) self.assertIn('501', e.message)
def test_resource_can_be_added_as_extension(self): def test_resource_can_be_added_as_extension(self):
res_ext = extensions.ResourceExtension( res_ext = extensions.ResourceExtension(
@ -438,7 +438,7 @@ class ExtensionManagerTest(base.BaseTestCase):
ext_mgr.add_extension(InvalidExtension()) ext_mgr.add_extension(InvalidExtension())
ext_mgr.add_extension(ext_stubs.StubExtension("valid_extension")) ext_mgr.add_extension(ext_stubs.StubExtension("valid_extension"))
self.assertTrue('valid_extension' in ext_mgr.extensions) self.assertIn('valid_extension', ext_mgr.extensions)
self.assertNotIn('invalid_extension', ext_mgr.extensions) self.assertNotIn('invalid_extension', ext_mgr.extensions)
@ -453,9 +453,9 @@ class PluginAwareExtensionManagerTest(base.BaseTestCase):
ext_mgr.add_extension(ext_stubs.StubExtension("e2")) ext_mgr.add_extension(ext_stubs.StubExtension("e2"))
ext_mgr.add_extension(ext_stubs.StubExtension("e3")) ext_mgr.add_extension(ext_stubs.StubExtension("e3"))
self.assertTrue("e1" in ext_mgr.extensions) self.assertIn("e1", ext_mgr.extensions)
self.assertNotIn("e2", ext_mgr.extensions) self.assertNotIn("e2", ext_mgr.extensions)
self.assertTrue("e3" in ext_mgr.extensions) self.assertIn("e3", ext_mgr.extensions)
def test_extensions_are_not_loaded_for_plugins_unaware_of_extensions(self): def test_extensions_are_not_loaded_for_plugins_unaware_of_extensions(self):
class ExtensionUnawarePlugin(object): class ExtensionUnawarePlugin(object):
@ -498,7 +498,7 @@ class PluginAwareExtensionManagerTest(base.BaseTestCase):
ext_mgr.add_extension( ext_mgr.add_extension(
ext_stubs.ExtensionExpectingPluginInterface("supported_extension")) ext_stubs.ExtensionExpectingPluginInterface("supported_extension"))
self.assertTrue("supported_extension" in ext_mgr.extensions) self.assertIn("supported_extension", ext_mgr.extensions)
def test_extensions_expecting_neutron_plugin_interface_are_loaded(self): def test_extensions_expecting_neutron_plugin_interface_are_loaded(self):
class ExtensionForQuamtumPluginInterface(ext_stubs.StubExtension): class ExtensionForQuamtumPluginInterface(ext_stubs.StubExtension):
@ -512,7 +512,7 @@ class PluginAwareExtensionManagerTest(base.BaseTestCase):
ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info) ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info)
ext_mgr.add_extension(ExtensionForQuamtumPluginInterface("e1")) ext_mgr.add_extension(ExtensionForQuamtumPluginInterface("e1"))
self.assertTrue("e1" in ext_mgr.extensions) self.assertIn("e1", ext_mgr.extensions)
def test_extensions_without_need_for__plugin_interface_are_loaded(self): def test_extensions_without_need_for__plugin_interface_are_loaded(self):
class ExtensionWithNoNeedForPluginInterface(ext_stubs.StubExtension): class ExtensionWithNoNeedForPluginInterface(ext_stubs.StubExtension):
@ -528,7 +528,7 @@ class PluginAwareExtensionManagerTest(base.BaseTestCase):
ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info) ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info)
ext_mgr.add_extension(ExtensionWithNoNeedForPluginInterface("e1")) ext_mgr.add_extension(ExtensionWithNoNeedForPluginInterface("e1"))
self.assertTrue("e1" in ext_mgr.extensions) self.assertIn("e1", ext_mgr.extensions)
def test_extension_loaded_for_non_core_plugin(self): def test_extension_loaded_for_non_core_plugin(self):
class NonCorePluginExtenstion(ext_stubs.StubExtension): class NonCorePluginExtenstion(ext_stubs.StubExtension):
@ -540,7 +540,7 @@ class PluginAwareExtensionManagerTest(base.BaseTestCase):
ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info) ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info)
ext_mgr.add_extension(NonCorePluginExtenstion("e1")) ext_mgr.add_extension(NonCorePluginExtenstion("e1"))
self.assertTrue("e1" in ext_mgr.extensions) self.assertIn("e1", ext_mgr.extensions)
class ExtensionControllerTest(testlib_api.WebTestCase): class ExtensionControllerTest(testlib_api.WebTestCase):

View File

@ -238,7 +238,7 @@ class ServiceTypeManagerExtTestCase(ServiceTypeExtensionTestCaseBase):
res = self._list_service_providers() res = self._list_service_providers()
self.assertEqual(res.status_int, webexc.HTTPOk.code) self.assertEqual(res.status_int, webexc.HTTPOk.code)
data = self.deserialize(res) data = self.deserialize(res)
self.assertTrue('service_providers' in data) self.assertIn('service_providers', data)
self.assertEqual(len(data['service_providers']), 2) self.assertEqual(len(data['service_providers']), 2)