Use assert(Not)Empty,IsNotNone instead of assert(Not)Equal,GreaterEqual(0, len(..
This commit makes to use assert(Not)Empty() or assertIsNotNone() instead of assert(Not)Equal(0, len(LIST),..) or assertGreaterEqual(0, len()...). The original code asserts the specified list is empty or not. And we already have assert(Not)Empty() for it. The method names "assert(Not)Empty" are straightforward and easy to understand. It makes the code clean and the assert message could be easier to understand what is happen than original ones. Change-Id: I715ec84d9139b1d196275e91212ab40d52a545e1
This commit is contained in:
parent
d8ab06b17c
commit
f9009b4869
|
@ -86,8 +86,7 @@ class AgentsAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||
body = self.client.create_agent(**self.params_agent)['agent']
|
||||
self.addCleanup(self.client.delete_agent, body['agent_id'])
|
||||
agents = self.client.list_agents()['agents']
|
||||
self.assertGreater(len(agents), 0,
|
||||
'Cannot get any agents.(%s)' % agents)
|
||||
self.assertNotEmpty(agents, 'Cannot get any agents.(%s)' % agents)
|
||||
self.assertIn(body['agent_id'], map(lambda x: x['agent_id'], agents))
|
||||
|
||||
@decorators.idempotent_id('eabadde4-3cd7-4ec4-a4b5-5a936d2d4408')
|
||||
|
@ -105,8 +104,7 @@ class AgentsAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||
agent_id_xen = agent_xen['agent_id']
|
||||
agents = (self.client.list_agents(hypervisor=agent_xen['hypervisor'])
|
||||
['agents'])
|
||||
self.assertGreater(len(agents), 0,
|
||||
'Cannot get any agents.(%s)' % agents)
|
||||
self.assertNotEmpty(agents, 'Cannot get any agents.(%s)' % agents)
|
||||
self.assertIn(agent_id_xen, map(lambda x: x['agent_id'], agents))
|
||||
self.assertNotIn(body['agent_id'], map(lambda x: x['agent_id'],
|
||||
agents))
|
||||
|
|
|
@ -29,10 +29,10 @@ class AZAdminV2TestJSON(base.BaseV2ComputeAdminTest):
|
|||
def test_get_availability_zone_list(self):
|
||||
# List of availability zone
|
||||
availability_zone = self.client.list_availability_zones()
|
||||
self.assertGreater(len(availability_zone['availabilityZoneInfo']), 0)
|
||||
self.assertNotEmpty(availability_zone['availabilityZoneInfo'])
|
||||
|
||||
@decorators.idempotent_id('ef726c58-530f-44c2-968c-c7bed22d5b8c')
|
||||
def test_get_availability_zone_list_detail(self):
|
||||
# List of availability zones and available services
|
||||
availability_zone = self.client.list_availability_zones(detail=True)
|
||||
self.assertGreater(len(availability_zone['availabilityZoneInfo']), 0)
|
||||
self.assertNotEmpty(availability_zone['availabilityZoneInfo'])
|
||||
|
|
|
@ -73,7 +73,7 @@ class FloatingIPsBulkAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||
self.client.delete_floating_ips_bulk, self.ip_range)
|
||||
self.assertEqual(self.ip_range, body['ip_range'])
|
||||
ips_list = self.client.list_floating_ips_bulk()['floating_ip_info']
|
||||
self.assertNotEqual(0, len(ips_list))
|
||||
self.assertNotEmpty(ips_list)
|
||||
for ip in netaddr.IPNetwork(self.ip_range).iter_hosts():
|
||||
self.assertIn(str(ip), map(lambda x: x['address'], ips_list))
|
||||
body = (self.client.delete_floating_ips_bulk(self.ip_range)
|
||||
|
|
|
@ -44,14 +44,14 @@ class HostsAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||
# If send the request with a blank zone, the request will be successful
|
||||
# and it will return all the hosts list
|
||||
hosts = self.client.list_hosts(zone='')['hosts']
|
||||
self.assertNotEqual(0, len(hosts))
|
||||
self.assertNotEmpty(hosts)
|
||||
|
||||
@decorators.idempotent_id('c6ddbadb-c94e-4500-b12f-8ffc43843ff8')
|
||||
def test_list_hosts_with_nonexistent_zone(self):
|
||||
# If send the request with a nonexistent zone, the request will be
|
||||
# successful and no hosts will be returned
|
||||
hosts = self.client.list_hosts(zone='xxx')['hosts']
|
||||
self.assertEqual(0, len(hosts))
|
||||
self.assertEmpty(hosts)
|
||||
|
||||
@decorators.idempotent_id('38adbb12-aee2-4498-8aec-329c72423aa4')
|
||||
def test_show_host_detail(self):
|
||||
|
|
|
@ -31,7 +31,7 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||
return hypers
|
||||
|
||||
def assertHypervisors(self, hypers):
|
||||
self.assertGreater(len(hypers), 0, "No hypervisors found: %s" % hypers)
|
||||
self.assertNotEmpty(hypers, "No hypervisors found: %s" % hypers)
|
||||
|
||||
@decorators.idempotent_id('7f0ceacd-c64d-4e96-b8ee-d02943142cc5')
|
||||
def test_get_hypervisor_list(self):
|
||||
|
@ -52,7 +52,7 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||
self.assertHypervisors(hypers)
|
||||
|
||||
details = self.client.show_hypervisor(hypers[0]['id'])['hypervisor']
|
||||
self.assertGreater(len(details), 0)
|
||||
self.assertNotEmpty(details)
|
||||
self.assertEqual(details['hypervisor_hostname'],
|
||||
hypers[0]['hypervisor_hostname'])
|
||||
|
||||
|
@ -65,14 +65,14 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||
hostname = hypers[0]['hypervisor_hostname']
|
||||
hypervisors = (self.client.list_servers_on_hypervisor(hostname)
|
||||
['hypervisors'])
|
||||
self.assertGreater(len(hypervisors), 0)
|
||||
self.assertNotEmpty(hypervisors)
|
||||
|
||||
@decorators.idempotent_id('797e4f28-b6e0-454d-a548-80cc77c00816')
|
||||
def test_get_hypervisor_stats(self):
|
||||
# Verify the stats of the all hypervisor
|
||||
stats = (self.client.show_hypervisor_statistics()
|
||||
['hypervisor_statistics'])
|
||||
self.assertGreater(len(stats), 0)
|
||||
self.assertNotEmpty(stats)
|
||||
|
||||
@decorators.idempotent_id('91a50d7d-1c2b-4f24-b55a-a1fe20efca70')
|
||||
def test_get_hypervisor_uptime(self):
|
||||
|
|
|
@ -47,7 +47,7 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
|||
@decorators.idempotent_id('51e663d0-6b89-4817-a465-20aca0667d03')
|
||||
def test_show_hypervisor_with_non_admin_user(self):
|
||||
hypers = self._list_hypervisors()
|
||||
self.assertGreater(len(hypers), 0)
|
||||
self.assertNotEmpty(hypers)
|
||||
|
||||
self.assertRaises(
|
||||
lib_exc.Forbidden,
|
||||
|
@ -58,7 +58,7 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
|||
@decorators.idempotent_id('2a0a3938-832e-4859-95bf-1c57c236b924')
|
||||
def test_show_servers_with_non_admin_user(self):
|
||||
hypers = self._list_hypervisors()
|
||||
self.assertGreater(len(hypers), 0)
|
||||
self.assertNotEmpty(hypers)
|
||||
|
||||
self.assertRaises(
|
||||
lib_exc.Forbidden,
|
||||
|
@ -96,7 +96,7 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
|||
@decorators.idempotent_id('6c3461f9-c04c-4e2a-bebb-71dc9cb47df2')
|
||||
def test_get_hypervisor_uptime_with_non_admin_user(self):
|
||||
hypers = self._list_hypervisors()
|
||||
self.assertGreater(len(hypers), 0)
|
||||
self.assertNotEmpty(hypers)
|
||||
|
||||
self.assertRaises(
|
||||
lib_exc.Forbidden,
|
||||
|
@ -131,7 +131,7 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
|||
@decorators.idempotent_id('5b6a6c79-5dc1-4fa5-9c58-9c8085948e74')
|
||||
def test_search_hypervisor_with_non_admin_user(self):
|
||||
hypers = self._list_hypervisors()
|
||||
self.assertGreater(len(hypers), 0)
|
||||
self.assertNotEmpty(hypers)
|
||||
|
||||
self.assertRaises(
|
||||
lib_exc.Forbidden,
|
||||
|
|
|
@ -111,7 +111,7 @@ class SecurityGroupDefaultRulesTest(base.BaseV2ComputeAdminTest):
|
|||
rule['id'])
|
||||
rules = (self.adm_client.list_security_group_default_rules()
|
||||
['security_group_default_rules'])
|
||||
self.assertNotEqual(0, len(rules))
|
||||
self.assertNotEmpty(rules)
|
||||
self.assertIn(rule, rules)
|
||||
|
||||
@decorators.idempotent_id('15cbb349-86b4-4f71-a048-04b7ef3f150b')
|
||||
|
|
|
@ -29,13 +29,13 @@ class ServicesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||
@decorators.idempotent_id('5be41ef4-53d1-41cc-8839-5c2a48a1b283')
|
||||
def test_list_services(self):
|
||||
services = self.client.list_services()['services']
|
||||
self.assertNotEqual(0, len(services))
|
||||
self.assertNotEmpty(services)
|
||||
|
||||
@decorators.idempotent_id('f345b1ec-bc6e-4c38-a527-3ca2bc00bef5')
|
||||
def test_get_service_by_service_binary_name(self):
|
||||
binary_name = 'nova-compute'
|
||||
services = self.client.list_services(binary=binary_name)['services']
|
||||
self.assertNotEqual(0, len(services))
|
||||
self.assertNotEmpty(services)
|
||||
for service in services:
|
||||
self.assertEqual(binary_name, service['binary'])
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class ServicesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
|||
host_name = services[0]['host']
|
||||
services = self.client.list_services(host=host_name,
|
||||
binary='xxx')['services']
|
||||
self.assertEqual(0, len(services))
|
||||
self.assertEmpty(services)
|
||||
|
||||
@decorators.attr(type=['negative'])
|
||||
@decorators.idempotent_id('64e7e7fb-69e8-4cb6-a71d-8d5eb0c98655')
|
||||
|
@ -57,4 +57,4 @@ class ServicesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
|||
binary_name = services[0]['binary']
|
||||
services = self.client.list_services(host='xxx',
|
||||
binary=binary_name)['services']
|
||||
self.assertEqual(0, len(services))
|
||||
self.assertEmpty(services)
|
||||
|
|
|
@ -58,7 +58,7 @@ class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest):
|
|||
# Positive test:Should return the list of floating IPs
|
||||
body = self.client.list_floating_ips()['floating_ips']
|
||||
floating_ips = body
|
||||
self.assertNotEqual(0, len(floating_ips),
|
||||
self.assertNotEmpty(floating_ips,
|
||||
"Expected floating IPs. Got zero.")
|
||||
for i in range(3):
|
||||
self.assertIn(self.floating_ip[i], floating_ips)
|
||||
|
@ -90,5 +90,5 @@ class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest):
|
|||
def test_list_floating_ip_pools(self):
|
||||
# Positive test:Should return the list of floating IP Pools
|
||||
floating_ip_pools = self.pools_client.list_floating_ip_pools()
|
||||
self.assertNotEqual(0, len(floating_ip_pools['floating_ip_pools']),
|
||||
self.assertNotEmpty(floating_ip_pools['floating_ip_pools'],
|
||||
"Expected floating IP Pools. Got zero.")
|
||||
|
|
|
@ -42,6 +42,6 @@ class AbsoluteLimitsTestJSON(base.BaseV2ComputeTest):
|
|||
# check whether all expected elements exist
|
||||
missing_elements =\
|
||||
[ele for ele in expected_elements if ele not in absolute_limits]
|
||||
self.assertEqual(0, len(missing_elements),
|
||||
self.assertEmpty(missing_elements,
|
||||
"Failed to find element %s in absolute limits list"
|
||||
% ', '.join(ele for ele in missing_elements))
|
||||
|
|
|
@ -186,4 +186,4 @@ class SecurityGroupRulesTestJSON(base.BaseSecurityGroupsTest):
|
|||
rules = (self.security_groups_client.show_security_group(sg1_id)
|
||||
['security_group']['rules'])
|
||||
# The group1 has no rules because group2 has deleted
|
||||
self.assertEqual(0, len(rules))
|
||||
self.assertEmpty(rules)
|
||||
|
|
|
@ -29,4 +29,4 @@ class AZV2TestJSON(base.BaseV2ComputeTest):
|
|||
def test_get_availability_zone_list_with_non_admin_user(self):
|
||||
# List of availability zone with non-administrator user
|
||||
availability_zone = self.client.list_availability_zones()
|
||||
self.assertGreater(len(availability_zone['availabilityZoneInfo']), 0)
|
||||
self.assertNotEmpty(availability_zone['availabilityZoneInfo'])
|
||||
|
|
|
@ -142,7 +142,7 @@ class ListServerFiltersTestJSON(base.BaseV2ComputeTest):
|
|||
# Verify only the expected number of servers are returned
|
||||
params = {'limit': 0}
|
||||
servers = self.client.list_servers(**params)
|
||||
self.assertEqual(0, len(servers['servers']))
|
||||
self.assertEmpty(servers['servers'])
|
||||
|
||||
@decorators.idempotent_id('37791bbd-90c0-4de0-831e-5f38cba9c6b3')
|
||||
def test_list_servers_filter_by_exceed_limit(self):
|
||||
|
|
|
@ -122,7 +122,7 @@ class ListServersNegativeTestJSON(base.BaseV2ComputeTest):
|
|||
# Return an empty list when a date in the future is passed
|
||||
changes_since = {'changes-since': '2051-01-01T12:34:00Z'}
|
||||
body = self.client.list_servers(**changes_since)
|
||||
self.assertEqual(0, len(body['servers']))
|
||||
self.assertEmpty(body['servers'])
|
||||
|
||||
@decorators.attr(type=['negative'])
|
||||
@decorators.idempotent_id('93055106-2d34-46fe-af68-d9ddbf7ee570')
|
||||
|
|
|
@ -58,7 +58,7 @@ class VirtualInterfacesTestJSON(base.BaseV2ComputeTest):
|
|||
output = self.client.list_virtual_interfaces(self.server['id'])
|
||||
self.assertIsNotNone(output)
|
||||
virt_ifaces = output
|
||||
self.assertNotEqual(0, len(virt_ifaces['virtual_interfaces']),
|
||||
self.assertNotEmpty(virt_ifaces['virtual_interfaces'],
|
||||
'Expected virtual interfaces, got 0 '
|
||||
'interfaces.')
|
||||
for virt_iface in virt_ifaces['virtual_interfaces']:
|
||||
|
|
|
@ -62,7 +62,7 @@ class EndPointsTestJSON(base.BaseIdentityV2AdminTest):
|
|||
# Asserting LIST endpoints
|
||||
missing_endpoints =\
|
||||
[e for e in self.setup_endpoints if e not in fetched_endpoints]
|
||||
self.assertEqual(0, len(missing_endpoints),
|
||||
self.assertEmpty(missing_endpoints,
|
||||
"Failed to find endpoint %s in fetched list" %
|
||||
', '.join(str(e) for e in missing_endpoints))
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ class UsersTestJSON(base.BaseIdentityV2AdminTest):
|
|||
# verifying the user Id in the list
|
||||
missing_users =\
|
||||
[user for user in user_ids if user not in fetched_user_ids]
|
||||
self.assertEqual(0, len(missing_users),
|
||||
self.assertEmpty(missing_users,
|
||||
"Failed to find user %s in fetched list" %
|
||||
', '.join(m_user for m_user in missing_users))
|
||||
|
||||
|
@ -169,7 +169,7 @@ class UsersTestJSON(base.BaseIdentityV2AdminTest):
|
|||
# verifying the user Id in the list
|
||||
missing_users = [missing_user for missing_user in user_ids
|
||||
if missing_user not in fetched_user_ids]
|
||||
self.assertEqual(0, len(missing_users),
|
||||
self.assertEmpty(missing_users,
|
||||
"Failed to find user %s in fetched list" %
|
||||
', '.join(m_user for m_user in missing_users))
|
||||
|
||||
|
|
|
@ -107,6 +107,6 @@ class CredentialsTestJSON(base.BaseIdentityV3AdminTest):
|
|||
fetched_cred_ids.append(i['id'])
|
||||
missing_creds = [c for c in created_cred_ids
|
||||
if c not in fetched_cred_ids]
|
||||
self.assertEqual(0, len(missing_creds),
|
||||
self.assertEmpty(missing_creds,
|
||||
"Failed to find cred %s in fetched list" %
|
||||
', '.join(m_cred for m_cred in missing_creds))
|
||||
|
|
|
@ -57,7 +57,7 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest):
|
|||
fetched_ids.append(d['id'])
|
||||
missing_doms = [d for d in self.setup_domains
|
||||
if d['id'] not in fetched_ids]
|
||||
self.assertEqual(0, len(missing_doms))
|
||||
self.assertEmpty(missing_doms)
|
||||
|
||||
@decorators.idempotent_id('c6aee07b-4981-440c-bb0b-eb598f58ffe9')
|
||||
def test_list_domains_filter_by_name(self):
|
||||
|
|
|
@ -64,7 +64,7 @@ class EndPointsTestJSON(base.BaseIdentityV3AdminTest):
|
|||
# Asserting LIST endpoints
|
||||
missing_endpoints =\
|
||||
[e for e in self.setup_endpoints if e not in fetched_endpoints]
|
||||
self.assertEqual(0, len(missing_endpoints),
|
||||
self.assertEmpty(missing_endpoints,
|
||||
"Failed to find endpoint %s in fetched list" %
|
||||
', '.join(str(e) for e in missing_endpoints))
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class UsersV3TestJSON(base.BaseIdentityV3AdminTest):
|
|||
fetched_ids = [u['id'] for u in body]
|
||||
missing_users = [u['id'] for u in self.users
|
||||
if u['id'] not in fetched_ids]
|
||||
self.assertEqual(0, len(missing_users),
|
||||
self.assertEmpty(missing_users,
|
||||
"Failed to find user %s in fetched list" %
|
||||
', '.join(m_user for m_user in missing_users))
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class PoliciesTestJSON(base.BaseIdentityV3AdminTest):
|
|||
for p in body:
|
||||
fetched_ids.append(p['id'])
|
||||
missing_pols = [p for p in policy_ids if p not in fetched_ids]
|
||||
self.assertEqual(0, len(missing_pols))
|
||||
self.assertEmpty(missing_pols)
|
||||
|
||||
@decorators.attr(type='smoke')
|
||||
@decorators.idempotent_id('e544703a-2f03-4cf2-9b0f-350782fdb0d3')
|
||||
|
|
|
@ -98,7 +98,7 @@ class RegionsTestJSON(base.BaseIdentityV3AdminTest):
|
|||
missing_regions =\
|
||||
[e for e in self.setup_regions if e not in fetched_regions]
|
||||
# Asserting List Regions response
|
||||
self.assertEqual(0, len(missing_regions),
|
||||
self.assertEmpty(missing_regions,
|
||||
"Failed to find region %s in fetched list" %
|
||||
', '.join(str(e) for e in missing_regions))
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ class UsersV3TestJSON(base.BaseIdentityV3AdminTest):
|
|||
missing_projects =\
|
||||
[p for p in assigned_project_ids
|
||||
if p not in fetched_project_ids]
|
||||
self.assertEqual(0, len(missing_projects),
|
||||
self.assertEmpty(missing_projects,
|
||||
"Failed to find project %s in fetched list" %
|
||||
', '.join(m_project for m_project
|
||||
in missing_projects))
|
||||
|
|
|
@ -54,15 +54,13 @@ class TokensV3Test(base.BaseIdentityV3Test):
|
|||
self.assertEqual(subject_id, user_id)
|
||||
else:
|
||||
# Expect a user ID, but don't know what it will be.
|
||||
self.assertGreaterEqual(len(subject_id), 0,
|
||||
'Expected user ID in token.')
|
||||
self.assertIsNotNone(subject_id, 'Expected user ID in token.')
|
||||
|
||||
subject_name = resp['user']['name']
|
||||
if username:
|
||||
self.assertEqual(subject_name, username)
|
||||
else:
|
||||
# Expect a user name, but don't know what it will be.
|
||||
self.assertGreaterEqual(len(subject_name), 0,
|
||||
'Expected user name in token.')
|
||||
self.assertIsNotNone(subject_name, 'Expected user name in token.')
|
||||
|
||||
self.assertEqual(resp['methods'][0], 'password')
|
||||
|
|
|
@ -54,6 +54,6 @@ class ImageMembersTest(base.BaseV1ImageMembersTest):
|
|||
self.alt_tenant_id)
|
||||
body = self.image_member_client.list_image_members(image_id)
|
||||
members = body['members']
|
||||
self.assertEqual(0, len(members), str(members))
|
||||
self.assertEmpty(members)
|
||||
self.assertRaises(
|
||||
lib_exc.NotFound, self.alt_img_cli.show_image, image_id)
|
||||
|
|
|
@ -89,7 +89,7 @@ class MeteringTestJSON(base.BaseAdminNetworkTest):
|
|||
# Verify label filtering
|
||||
body = self.admin_metering_labels_client.list_metering_labels(id=33)
|
||||
metering_labels = body['metering_labels']
|
||||
self.assertEqual(0, len(metering_labels))
|
||||
self.assertEmpty(metering_labels)
|
||||
|
||||
@decorators.idempotent_id('ec8e15ff-95d0-433b-b8a6-b466bddb1e50')
|
||||
def test_create_delete_metering_label_with_filters(self):
|
||||
|
@ -126,7 +126,7 @@ class MeteringTestJSON(base.BaseAdminNetworkTest):
|
|||
# Verify rule filtering
|
||||
body = client.list_metering_label_rules(id=33)
|
||||
metering_label_rules = body['metering_label_rules']
|
||||
self.assertEqual(0, len(metering_label_rules))
|
||||
self.assertEmpty(metering_label_rules)
|
||||
|
||||
@decorators.idempotent_id('f4d547cd-3aee-408f-bf36-454f8825e045')
|
||||
def test_create_delete_metering_label_rule_with_filters(self):
|
||||
|
|
|
@ -41,13 +41,13 @@ class VolumesServicesTestJSON(base.BaseVolumeAdminTest):
|
|||
def test_list_services(self):
|
||||
services = (self.admin_volume_services_client.list_services()
|
||||
['services'])
|
||||
self.assertNotEqual(0, len(services))
|
||||
self.assertNotEmpty(services)
|
||||
|
||||
@decorators.idempotent_id('63a3e1ca-37ee-4983-826d-83276a370d25')
|
||||
def test_get_service_by_service_binary_name(self):
|
||||
services = (self.admin_volume_services_client.list_services(
|
||||
binary=self.binary_name)['services'])
|
||||
self.assertNotEqual(0, len(services))
|
||||
self.assertNotEmpty(services)
|
||||
for service in services:
|
||||
self.assertEqual(self.binary_name, service['binary'])
|
||||
|
||||
|
@ -76,7 +76,7 @@ class VolumesServicesTestJSON(base.BaseVolumeAdminTest):
|
|||
services = (self.admin_volume_services_client.list_services(
|
||||
host=hostname, binary='cinder-volume')['services'])
|
||||
|
||||
self.assertNotEqual(0, len(services),
|
||||
self.assertNotEmpty(services,
|
||||
'cinder-volume not found on host %s' % hostname)
|
||||
self.assertEqual(hostname, _get_host(services[0]['host']))
|
||||
self.assertEqual('cinder-volume', services[0]['binary'])
|
||||
|
@ -87,6 +87,6 @@ class VolumesServicesTestJSON(base.BaseVolumeAdminTest):
|
|||
services = (self.admin_volume_services_client.list_services(
|
||||
host=self.host_name, binary=self.binary_name))['services']
|
||||
|
||||
self.assertNotEqual(0, len(services))
|
||||
self.assertNotEmpty(services)
|
||||
self.assertEqual(self.host_name, _get_host(services[0]['host']))
|
||||
self.assertEqual(self.binary_name, services[0]['binary'])
|
||||
|
|
|
@ -30,4 +30,4 @@ class AvailabilityZoneTestJSON(base.BaseVolumeTest):
|
|||
# List of availability zone
|
||||
availability_zone = (self.client.list_availability_zones()
|
||||
['availabilityZoneInfo'])
|
||||
self.assertGreater(len(availability_zone), 0)
|
||||
self.assertNotEmpty(availability_zone)
|
||||
|
|
|
@ -261,7 +261,7 @@ class VolumesNegativeTest(base.BaseVolumeTest):
|
|||
params = {'name': v_name}
|
||||
fetched_volume = self.volumes_client.list_volumes(
|
||||
params=params)['volumes']
|
||||
self.assertEqual(0, len(fetched_volume))
|
||||
self.assertEmpty(fetched_volume)
|
||||
|
||||
@decorators.attr(type=['negative'])
|
||||
@decorators.idempotent_id('9ca17820-a0e7-4cbd-a7fa-f4468735e359')
|
||||
|
@ -271,7 +271,7 @@ class VolumesNegativeTest(base.BaseVolumeTest):
|
|||
fetched_volume = \
|
||||
self.volumes_client.list_volumes(
|
||||
detail=True, params=params)['volumes']
|
||||
self.assertEqual(0, len(fetched_volume))
|
||||
self.assertEmpty(fetched_volume)
|
||||
|
||||
@decorators.attr(type=['negative'])
|
||||
@decorators.idempotent_id('143b279b-7522-466b-81be-34a87d564a7c')
|
||||
|
@ -279,7 +279,7 @@ class VolumesNegativeTest(base.BaseVolumeTest):
|
|||
params = {'status': 'null'}
|
||||
fetched_volume = self.volumes_client.list_volumes(
|
||||
params=params)['volumes']
|
||||
self.assertEqual(0, len(fetched_volume))
|
||||
self.assertEmpty(fetched_volume)
|
||||
|
||||
@decorators.attr(type=['negative'])
|
||||
@decorators.idempotent_id('ba94b27b-be3f-496c-a00e-0283b373fa75')
|
||||
|
@ -288,7 +288,7 @@ class VolumesNegativeTest(base.BaseVolumeTest):
|
|||
fetched_volume = \
|
||||
self.volumes_client.list_volumes(detail=True,
|
||||
params=params)['volumes']
|
||||
self.assertEqual(0, len(fetched_volume))
|
||||
self.assertEmpty(fetched_volume)
|
||||
|
||||
@decorators.attr(type=['negative'])
|
||||
@decorators.idempotent_id('5b810c91-0ad1-47ce-aee8-615f789be78f')
|
||||
|
|
|
@ -811,7 +811,7 @@ class NetworkScenarioTest(ScenarioTest):
|
|||
if inactive:
|
||||
LOG.warning("Instance has ports that are not ACTIVE: %s", inactive)
|
||||
|
||||
self.assertNotEqual(0, len(port_map),
|
||||
self.assertNotEmpty(port_map,
|
||||
"No IPv4 addresses found in: %s" % ports)
|
||||
self.assertEqual(len(port_map), 1,
|
||||
"Found multiple IPv4 addresses: %s. "
|
||||
|
@ -1029,7 +1029,7 @@ class NetworkScenarioTest(ScenarioTest):
|
|||
if sg['tenant_id'] == tenant_id and sg['name'] == 'default'
|
||||
]
|
||||
msg = "No default security group for tenant %s." % (tenant_id)
|
||||
self.assertGreater(len(sgs), 0, msg)
|
||||
self.assertNotEmpty(sgs, msg)
|
||||
return sgs[0]
|
||||
|
||||
def _create_security_group_rule(self, secgroup=None,
|
||||
|
|
Loading…
Reference in New Issue