Modify use of assertTrue(A in B)
Developers should use assertIn(A, B) instead of assertTrue(A in B ). Developers should use assertNotIn(A, B) instead of assertFalse(A in B ). TrivialFix Change-Id: Ibfb5bda501015383ac170544129c280f99f4f5ed
This commit is contained in:
parent
b0e9d4f1aa
commit
211c465c0b
@ -53,9 +53,9 @@ class TestClusterHandlers(BaseIntegrationTest):
|
|||||||
for resp_nic in resp.json_body:
|
for resp_nic in resp.json_body:
|
||||||
net_names = [net['name'] for net in resp_nic['assigned_networks']]
|
net_names = [net['name'] for net in resp_nic['assigned_networks']]
|
||||||
if resp_nic['mac'] == mac:
|
if resp_nic['mac'] == mac:
|
||||||
self.assertTrue("fuelweb_admin" in net_names)
|
self.assertIn("fuelweb_admin", net_names)
|
||||||
else:
|
else:
|
||||||
self.assertTrue("public" in net_names)
|
self.assertIn("public", net_names)
|
||||||
self.assertGreater(len(resp_nic['assigned_networks']), 0)
|
self.assertGreater(len(resp_nic['assigned_networks']), 0)
|
||||||
|
|
||||||
def test_assignment_is_removed_when_delete_node_from_cluster(self):
|
def test_assignment_is_removed_when_delete_node_from_cluster(self):
|
||||||
@ -121,9 +121,9 @@ class TestNodeHandlers(BaseIntegrationTest):
|
|||||||
for resp_nic in resp.json_body:
|
for resp_nic in resp.json_body:
|
||||||
net_names = [net['name'] for net in resp_nic['assigned_networks']]
|
net_names = [net['name'] for net in resp_nic['assigned_networks']]
|
||||||
if resp_nic['mac'] == mac:
|
if resp_nic['mac'] == mac:
|
||||||
self.assertTrue("fuelweb_admin" in net_names)
|
self.assertIn("fuelweb_admin", net_names)
|
||||||
else:
|
else:
|
||||||
self.assertTrue("public" in net_names)
|
self.assertIn("public", net_names)
|
||||||
self.assertGreater(len(resp_nic['assigned_networks']), 0)
|
self.assertGreater(len(resp_nic['assigned_networks']), 0)
|
||||||
|
|
||||||
def test_network_assignment_when_node_added(self):
|
def test_network_assignment_when_node_added(self):
|
||||||
@ -153,9 +153,9 @@ class TestNodeHandlers(BaseIntegrationTest):
|
|||||||
for resp_nic in response:
|
for resp_nic in response:
|
||||||
net_names = [net['name'] for net in resp_nic['assigned_networks']]
|
net_names = [net['name'] for net in resp_nic['assigned_networks']]
|
||||||
if resp_nic['mac'] == mac:
|
if resp_nic['mac'] == mac:
|
||||||
self.assertTrue("fuelweb_admin" in net_names)
|
self.assertIn("fuelweb_admin", net_names)
|
||||||
else:
|
else:
|
||||||
self.assertTrue("public" in net_names)
|
self.assertIn("public", net_names)
|
||||||
self.assertGreater(len(resp_nic['assigned_networks']), 0)
|
self.assertGreater(len(resp_nic['assigned_networks']), 0)
|
||||||
|
|
||||||
def _add_node_with_pxe_on_eth2(self, cluster_id, **kwargs):
|
def _add_node_with_pxe_on_eth2(self, cluster_id, **kwargs):
|
||||||
|
@ -189,9 +189,9 @@ class TestNodeCollectionNICsDefaultHandler(BaseIntegrationTest):
|
|||||||
self.assertEqual(len(resp.json_body), 2)
|
self.assertEqual(len(resp.json_body), 2)
|
||||||
|
|
||||||
macs = [iface['mac'] for node in resp.json_body for iface in node]
|
macs = [iface['mac'] for node in resp.json_body for iface in node]
|
||||||
self.assertTrue('01:01:01:01:01:01' in macs)
|
self.assertIn('01:01:01:01:01:01', macs)
|
||||||
self.assertTrue('02:02:02:02:02:02' in macs)
|
self.assertIn('02:02:02:02:02:02', macs)
|
||||||
self.assertFalse('03:03:03:03:03:03' in macs)
|
self.assertNotIn('03:03:03:03:03:03', macs)
|
||||||
|
|
||||||
def test_get_wo_cluster_id(self):
|
def test_get_wo_cluster_id(self):
|
||||||
# get nics of cluster and check that response is ok
|
# get nics of cluster and check that response is ok
|
||||||
@ -204,6 +204,6 @@ class TestNodeCollectionNICsDefaultHandler(BaseIntegrationTest):
|
|||||||
self.assertEqual(len(resp.json_body), 3)
|
self.assertEqual(len(resp.json_body), 3)
|
||||||
|
|
||||||
macs = [iface['mac'] for node in resp.json_body for iface in node]
|
macs = [iface['mac'] for node in resp.json_body for iface in node]
|
||||||
self.assertTrue('01:01:01:01:01:01' in macs)
|
self.assertIn('01:01:01:01:01:01', macs)
|
||||||
self.assertTrue('02:02:02:02:02:02' in macs)
|
self.assertIn('02:02:02:02:02:02', macs)
|
||||||
self.assertTrue('03:03:03:03:03:03' in macs)
|
self.assertIn('03:03:03:03:03:03', macs)
|
||||||
|
@ -54,13 +54,13 @@ class TestHandlers(BaseIntegrationTest):
|
|||||||
capacity_log = self._get_capacity_log_json()
|
capacity_log = self._get_capacity_log_json()
|
||||||
|
|
||||||
for field in ['id', 'report']:
|
for field in ['id', 'report']:
|
||||||
self.assertTrue(field in capacity_log)
|
self.assertIn(field, capacity_log)
|
||||||
|
|
||||||
report = capacity_log['report']
|
report = capacity_log['report']
|
||||||
|
|
||||||
report_fields = ['fuel_data', 'environment_stats', 'allocation_stats']
|
report_fields = ['fuel_data', 'environment_stats', 'allocation_stats']
|
||||||
for field in report_fields:
|
for field in report_fields:
|
||||||
self.assertTrue(field in report)
|
self.assertIn(field, report)
|
||||||
|
|
||||||
self.assertEqual(report['allocation_stats']['allocated'], 0)
|
self.assertEqual(report['allocation_stats']['allocated'], 0)
|
||||||
self.assertEqual(report['allocation_stats']['unallocated'], 1)
|
self.assertEqual(report['allocation_stats']['unallocated'], 1)
|
||||||
@ -90,7 +90,7 @@ class TestHandlers(BaseIntegrationTest):
|
|||||||
[],
|
[],
|
||||||
]
|
]
|
||||||
for row in csvreader:
|
for row in csvreader:
|
||||||
self.assertTrue(row in rows)
|
self.assertIn(row, rows)
|
||||||
|
|
||||||
@mock_rpc()
|
@mock_rpc()
|
||||||
def test_capacity_nodes_allocation(self):
|
def test_capacity_nodes_allocation(self):
|
||||||
|
@ -191,9 +191,9 @@ class TestInstallationInfo(BaseTestCase):
|
|||||||
self.assertEquals(cluster.fuel_version,
|
self.assertEquals(cluster.fuel_version,
|
||||||
cluster_info['fuel_version'])
|
cluster_info['fuel_version'])
|
||||||
|
|
||||||
self.assertTrue('attributes' in cluster_info)
|
self.assertIn('attributes', cluster_info)
|
||||||
|
|
||||||
self.assertTrue('release' in cluster_info)
|
self.assertIn('release', cluster_info)
|
||||||
self.assertEquals(cluster.release.operating_system,
|
self.assertEquals(cluster.release.operating_system,
|
||||||
cluster_info['release']['os'])
|
cluster_info['release']['os'])
|
||||||
self.assertEquals(cluster.release.name,
|
self.assertEquals(cluster.release.name,
|
||||||
@ -221,7 +221,7 @@ class TestInstallationInfo(BaseTestCase):
|
|||||||
})
|
})
|
||||||
clusters_info = info.get_clusters_info()
|
clusters_info = info.get_clusters_info()
|
||||||
cluster_info = clusters_info[0]
|
cluster_info = clusters_info[0]
|
||||||
self.assertTrue('network_configuration' in cluster_info)
|
self.assertIn('network_configuration', cluster_info)
|
||||||
network_config = cluster_info['network_configuration']
|
network_config = cluster_info['network_configuration']
|
||||||
|
|
||||||
for field in ('fixed_network_size', 'fixed_networks_vlan_start',
|
for field in ('fixed_network_size', 'fixed_networks_vlan_start',
|
||||||
@ -239,7 +239,7 @@ class TestInstallationInfo(BaseTestCase):
|
|||||||
# cluster_info
|
# cluster_info
|
||||||
cluster_info = filter(lambda x: x['net_provider'] == neutron,
|
cluster_info = filter(lambda x: x['net_provider'] == neutron,
|
||||||
clusters_info)[0]
|
clusters_info)[0]
|
||||||
self.assertTrue('network_configuration' in cluster_info)
|
self.assertIn('network_configuration', cluster_info)
|
||||||
network_config = cluster_info['network_configuration']
|
network_config = cluster_info['network_configuration']
|
||||||
|
|
||||||
for field in ('segmentation_type', 'net_l23_provider'):
|
for field in ('segmentation_type', 'net_l23_provider'):
|
||||||
@ -342,8 +342,8 @@ class TestInstallationInfo(BaseTestCase):
|
|||||||
self.assertEquals(len(nodes_params), info['allocated_nodes_num'])
|
self.assertEquals(len(nodes_params), info['allocated_nodes_num'])
|
||||||
self.assertEquals(len(unallocated_nodes_params),
|
self.assertEquals(len(unallocated_nodes_params),
|
||||||
info['unallocated_nodes_num'])
|
info['unallocated_nodes_num'])
|
||||||
self.assertTrue('master_node_uid' in info)
|
self.assertIn('master_node_uid', info)
|
||||||
self.assertTrue('contact_info_provided' in info['user_information'])
|
self.assertIn('contact_info_provided', info['user_information'])
|
||||||
self.assertDictEqual(settings.VERSION, info['fuel_release'])
|
self.assertDictEqual(settings.VERSION, info['fuel_release'])
|
||||||
|
|
||||||
def get_model_schema(self, model, with_relationships=True):
|
def get_model_schema(self, model, with_relationships=True):
|
||||||
|
@ -37,21 +37,21 @@ class TestHandlers(BaseIntegrationTest):
|
|||||||
for handler in urls:
|
for handler in urls:
|
||||||
test_url = reverse(handler, urls[handler])
|
test_url = reverse(handler, urls[handler])
|
||||||
resp = self.app.get(test_url, expect_errors=True)
|
resp = self.app.get(test_url, expect_errors=True)
|
||||||
self.assertTrue(resp.status_code in [404, 405])
|
self.assertIn(resp.status_code, [404, 405])
|
||||||
resp = self.app.delete(test_url, expect_errors=True)
|
resp = self.app.delete(test_url, expect_errors=True)
|
||||||
self.assertTrue(resp.status_code in [404, 405])
|
self.assertIn(resp.status_code, [404, 405])
|
||||||
resp = self.app.put(
|
resp = self.app.put(
|
||||||
test_url,
|
test_url,
|
||||||
json.dumps({}),
|
json.dumps({}),
|
||||||
expect_errors=True
|
expect_errors=True
|
||||||
)
|
)
|
||||||
self.assertTrue(resp.status_code in [404, 405])
|
self.assertIn(resp.status_code, [404, 405])
|
||||||
resp = self.app.post(
|
resp = self.app.post(
|
||||||
test_url,
|
test_url,
|
||||||
json.dumps({}),
|
json.dumps({}),
|
||||||
expect_errors=True
|
expect_errors=True
|
||||||
)
|
)
|
||||||
self.assertTrue(resp.status_code in [404, 405])
|
self.assertIn(resp.status_code, [404, 405])
|
||||||
|
|
||||||
def test_http_response(self):
|
def test_http_response(self):
|
||||||
web.ctx.headers = []
|
web.ctx.headers = []
|
||||||
|
Loading…
Reference in New Issue
Block a user