Merge "Use assert(Not)In/Greater(Equal)/LessEqual/IsNotNone"
This commit is contained in:
commit
44c186bc70
@ -800,7 +800,7 @@ class ResponseObjectTest(test.TestCase):
|
||||
robj = wsgi.ResponseObject({})
|
||||
robj['Header'] = 'foo'
|
||||
del robj['hEADER']
|
||||
self.assertFalse('header' in robj.headers)
|
||||
self.assertNotIn('header', robj.headers)
|
||||
|
||||
def test_header_isolation(self):
|
||||
robj = wsgi.ResponseObject({})
|
||||
|
@ -185,7 +185,7 @@ class ExperimentalAPITestCase(test.TestCase):
|
||||
self.assertEqual(experimental,
|
||||
response.headers.get(experimental_header_name))
|
||||
else:
|
||||
self.assertFalse(experimental_header_name in response.headers)
|
||||
self.assertNotIn(experimental_header_name, response.headers)
|
||||
|
||||
def test_experimental_api_called_when_requested(self):
|
||||
|
||||
@ -205,7 +205,7 @@ class ExperimentalAPITestCase(test.TestCase):
|
||||
response = self.req.get_response(self.app)
|
||||
|
||||
self.assertEqual(404, response.status_int)
|
||||
self.assertFalse(experimental_header_name in response.headers)
|
||||
self.assertNotIn(experimental_header_name, response.headers)
|
||||
|
||||
def test_experimental_header_returned_in_exception(self):
|
||||
|
||||
|
@ -108,9 +108,9 @@ class ShareNetworkAPITest(test.TestCase):
|
||||
|
||||
self.assertEqual(share_nw['created_at'], view['created_at'])
|
||||
self.assertEqual(share_nw['updated_at'], view['updated_at'])
|
||||
self.assertFalse('shares' in view)
|
||||
self.assertFalse('network_allocations' in view)
|
||||
self.assertFalse('security_services' in view)
|
||||
self.assertNotIn('shares', view)
|
||||
self.assertNotIn('network_allocations', view)
|
||||
self.assertNotIn('security_services', view)
|
||||
|
||||
@ddt.data(
|
||||
{'nova_net_id': 'fake_nova_net_id'},
|
||||
|
@ -186,7 +186,7 @@ class TestManilaMigrationsMySQL(ManilaMigrationsCheckers,
|
||||
text(sanity_check),
|
||||
database=self.engine.url.database)
|
||||
|
||||
self.assertTrue(total.scalar() > 0, "No tables found. Wrong schema?")
|
||||
self.assertGreater(total.scalar(), 0, "No tables found. Wrong schema?")
|
||||
|
||||
noninnodb_query = """
|
||||
SELECT count(*)
|
||||
|
@ -309,7 +309,7 @@ class ShareDatabaseAPITestCase(test.TestCase):
|
||||
self.assertTrue(expected_ss_keys.issubset(
|
||||
replica['share_server'].keys()))
|
||||
else:
|
||||
self.assertFalse('share_server' in replica.keys())
|
||||
self.assertNotIn('share_server', replica.keys())
|
||||
self.assertEqual(
|
||||
with_share_data,
|
||||
expected_share_keys.issubset(replica.keys()))
|
||||
@ -358,7 +358,7 @@ class ShareDatabaseAPITestCase(test.TestCase):
|
||||
self.assertTrue(expected_ss_keys.issubset(
|
||||
replica['share_server'].keys()))
|
||||
else:
|
||||
self.assertFalse('share_server' in replica.keys())
|
||||
self.assertNotIn('share_server', replica.keys())
|
||||
self.assertEqual(with_share_data,
|
||||
expected_share_keys.issubset(replica.keys()))
|
||||
|
||||
@ -1125,7 +1125,7 @@ class ShareInstanceExportLocationsMetadataDatabaseAPITestCase(test.TestCase):
|
||||
for el in els:
|
||||
if el.path == path:
|
||||
export_location_uuid = el.uuid
|
||||
self.assertFalse(export_location_uuid is None)
|
||||
self.assertIsNotNone(export_location_uuid)
|
||||
return export_location_uuid
|
||||
|
||||
def test_get_export_locations_by_share_id(self):
|
||||
@ -1529,7 +1529,7 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
filter_by(security_service_id=security_dict1['id']).\
|
||||
filter_by(share_network_id=self.share_nw_dict['id']).first()
|
||||
|
||||
self.assertTrue(result is not None)
|
||||
self.assertIsNotNone(result)
|
||||
|
||||
def test_add_security_service_not_found_01(self):
|
||||
security_service_id = 'unknown security service'
|
||||
@ -1593,7 +1593,7 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
||||
filter_by(security_service_id=security_dict1['id']).\
|
||||
filter_by(share_network_id=self.share_nw_dict['id']).first()
|
||||
|
||||
self.assertTrue(result is None)
|
||||
self.assertIsNone(result)
|
||||
|
||||
share_nw_ref = db_api.share_network_get(self.fake_context,
|
||||
self.share_nw_dict['id'])
|
||||
|
@ -531,7 +531,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
|
||||
shr = db.share_get(self.context, share_id)
|
||||
self.assertEqual(constants.STATUS_AVAILABLE, shr['status'])
|
||||
self.assertTrue(len(shr['export_location']) > 0)
|
||||
self.assertGreater(len(shr['export_location']), 0)
|
||||
self.assertEqual(2, len(shr['export_locations']))
|
||||
|
||||
def test_create_share_instance_for_share_with_replication_support(self):
|
||||
@ -1174,8 +1174,8 @@ class ShareManagerTestCase(test.TestCase):
|
||||
|
||||
self.assertEqual(2, mock_export_locs_update.call_count)
|
||||
self.assertEqual(2, mock_replica_update.call_count)
|
||||
self.assertTrue(
|
||||
reset_replication_change_call in mock_replica_update.mock_calls)
|
||||
self.assertIn(
|
||||
reset_replication_change_call, mock_replica_update.mock_calls)
|
||||
self.assertTrue(mock_info_log.called)
|
||||
self.assertFalse(mock_snap_instance_update.called)
|
||||
|
||||
@ -1739,7 +1739,7 @@ class ShareManagerTestCase(test.TestCase):
|
||||
shr = db.share_get(self.context, share_id)
|
||||
self.assertEqual(shr['status'], constants.STATUS_AVAILABLE)
|
||||
self.assertEqual(shr['share_server_id'], share_srv['id'])
|
||||
self.assertTrue(len(shr['export_location']) > 0)
|
||||
self.assertGreater(len(shr['export_location']), 0)
|
||||
self.assertEqual(1, len(shr['export_locations']))
|
||||
manager.LOG.info.assert_called_with(mock.ANY, share.instance['id'])
|
||||
|
||||
|
@ -399,20 +399,20 @@ class MonkeyPatchTestCase(test.TestCase):
|
||||
|
||||
self.assertEqual(8, ret_b)
|
||||
package_a = self.example_package + 'example_a.'
|
||||
self.assertTrue(package_a + 'example_function_a'
|
||||
in manila.tests.monkey_patch_example.CALLED_FUNCTION)
|
||||
self.assertIn(package_a + 'example_function_a',
|
||||
manila.tests.monkey_patch_example.CALLED_FUNCTION)
|
||||
|
||||
self.assertTrue(package_a + 'ExampleClassA.example_method'
|
||||
in manila.tests.monkey_patch_example.CALLED_FUNCTION)
|
||||
self.assertTrue(package_a + 'ExampleClassA.example_method_add'
|
||||
in manila.tests.monkey_patch_example.CALLED_FUNCTION)
|
||||
self.assertIn(package_a + 'ExampleClassA.example_method',
|
||||
manila.tests.monkey_patch_example.CALLED_FUNCTION)
|
||||
self.assertIn(package_a + 'ExampleClassA.example_method_add',
|
||||
manila.tests.monkey_patch_example.CALLED_FUNCTION)
|
||||
package_b = self.example_package + 'example_b.'
|
||||
self.assertFalse(package_b + 'example_function_b'
|
||||
in manila.tests.monkey_patch_example.CALLED_FUNCTION)
|
||||
self.assertFalse(package_b + 'ExampleClassB.example_method'
|
||||
in manila.tests.monkey_patch_example.CALLED_FUNCTION)
|
||||
self.assertFalse(package_b + 'ExampleClassB.example_method_add'
|
||||
in manila.tests.monkey_patch_example.CALLED_FUNCTION)
|
||||
self.assertNotIn(package_b + 'example_function_b',
|
||||
manila.tests.monkey_patch_example.CALLED_FUNCTION)
|
||||
self.assertNotIn(package_b + 'ExampleClassB.example_method',
|
||||
manila.tests.monkey_patch_example.CALLED_FUNCTION)
|
||||
self.assertNotIn(package_b + 'ExampleClassB.example_method_add',
|
||||
manila.tests.monkey_patch_example.CALLED_FUNCTION)
|
||||
|
||||
|
||||
class FakeSSHClient(object):
|
||||
|
@ -53,7 +53,7 @@ class ShareServersAdminTest(base.BaseSharesAdminTest):
|
||||
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
|
||||
def test_list_share_servers_without_filters(self):
|
||||
servers = self.shares_client.list_share_servers()
|
||||
self.assertTrue(len(servers) > 0)
|
||||
self.assertGreater(len(servers), 0)
|
||||
keys = [
|
||||
"id",
|
||||
"host",
|
||||
@ -70,11 +70,11 @@ class ShareServersAdminTest(base.BaseSharesAdminTest):
|
||||
if server["updated_at"]:
|
||||
self.assertTrue(self.date_re.match(server["updated_at"]))
|
||||
# Host is not empty
|
||||
self.assertTrue(len(server["host"]) > 0)
|
||||
self.assertGreater(len(server["host"]), 0)
|
||||
# Id is not empty
|
||||
self.assertTrue(len(server["id"]) > 0)
|
||||
self.assertGreater(len(server["id"]), 0)
|
||||
# Project id is not empty
|
||||
self.assertTrue(len(server["project_id"]) > 0)
|
||||
self.assertGreater(len(server["project_id"]), 0)
|
||||
|
||||
# Do not verify statuses because we get all share servers from whole
|
||||
# cluster and here can be servers with any state.
|
||||
@ -103,7 +103,7 @@ class ShareServersAdminTest(base.BaseSharesAdminTest):
|
||||
raise lib_exc.NotFound(message=msg)
|
||||
search_opts = {"host": host}
|
||||
servers = self.shares_client.list_share_servers(search_opts)
|
||||
self.assertTrue(len(servers) > 0)
|
||||
self.assertGreater(len(servers), 0)
|
||||
for server in servers:
|
||||
self.assertEqual(server["host"], host)
|
||||
|
||||
@ -129,7 +129,7 @@ class ShareServersAdminTest(base.BaseSharesAdminTest):
|
||||
raise lib_exc.NotFound(message=msg)
|
||||
search_opts = {"status": status}
|
||||
servers = self.shares_client.list_share_servers(search_opts)
|
||||
self.assertTrue(len(servers) > 0)
|
||||
self.assertGreater(len(servers), 0)
|
||||
for server in servers:
|
||||
self.assertEqual(server["status"], status)
|
||||
|
||||
@ -138,7 +138,7 @@ class ShareServersAdminTest(base.BaseSharesAdminTest):
|
||||
search_opts = {"project_id": self.share_network["project_id"]}
|
||||
servers = self.shares_client.list_share_servers(search_opts)
|
||||
# Should exist, at least, one share server, used by this test suite.
|
||||
self.assertTrue(len(servers) > 0)
|
||||
self.assertGreater(len(servers), 0)
|
||||
for server in servers:
|
||||
self.assertEqual(server["project_id"],
|
||||
self.share_network["project_id"])
|
||||
@ -148,7 +148,7 @@ class ShareServersAdminTest(base.BaseSharesAdminTest):
|
||||
search_opts = {"share_network": self.share_network["name"]}
|
||||
servers = self.shares_client.list_share_servers(search_opts)
|
||||
# Should exist, at least, one share server, used by this test suite.
|
||||
self.assertTrue(len(servers) > 0)
|
||||
self.assertGreater(len(servers), 0)
|
||||
for server in servers:
|
||||
self.assertEqual(server["share_network_name"],
|
||||
self.share_network["name"])
|
||||
@ -158,7 +158,7 @@ class ShareServersAdminTest(base.BaseSharesAdminTest):
|
||||
search_opts = {"share_network": self.share_network["id"]}
|
||||
servers = self.shares_client.list_share_servers(search_opts)
|
||||
# Should exist, at least, one share server, used by this test suite.
|
||||
self.assertTrue(len(servers) > 0)
|
||||
self.assertGreater(len(servers), 0)
|
||||
for server in servers:
|
||||
self.assertIn(server["share_network_name"],
|
||||
self.sn_name_and_id)
|
||||
@ -186,15 +186,15 @@ class ShareServersAdminTest(base.BaseSharesAdminTest):
|
||||
if server["updated_at"]:
|
||||
self.assertTrue(self.date_re.match(server["updated_at"]))
|
||||
# Host is not empty
|
||||
self.assertTrue(len(server["host"]) > 0)
|
||||
self.assertGreater(len(server["host"]), 0)
|
||||
# Id is not empty
|
||||
self.assertTrue(len(server["id"]) > 0)
|
||||
self.assertGreater(len(server["id"]), 0)
|
||||
# Project id is not empty
|
||||
self.assertTrue(len(server["project_id"]) > 0)
|
||||
self.assertGreater(len(server["project_id"]), 0)
|
||||
# Status is not empty
|
||||
self.assertTrue(len(server["status"]) > 0)
|
||||
self.assertGreater(len(server["status"]), 0)
|
||||
# share_network_name is not empty
|
||||
self.assertTrue(len(server["share_network_name"]) > 0)
|
||||
self.assertGreater(len(server["share_network_name"]), 0)
|
||||
# backend_details should be a dict
|
||||
self.assertIsInstance(server["backend_details"], dict)
|
||||
|
||||
|
@ -100,7 +100,7 @@ class ShareTypesAdminTest(base.BaseSharesAdminTest):
|
||||
# list share types
|
||||
st_list = self.shares_v2_client.list_share_types(version=version)
|
||||
sts = st_list["share_types"]
|
||||
self.assertTrue(len(sts) >= 1)
|
||||
self.assertGreaterEqual(len(sts), 1)
|
||||
self.assertTrue(any(st_id in st["id"] for st in sts))
|
||||
for st in sts:
|
||||
self._verify_is_public_key_name(st, version)
|
||||
|
@ -150,7 +150,7 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
|
||||
shares = self.shares_client.list_shares_with_detail(params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
for share in shares:
|
||||
self.assertDictContainsSubset(
|
||||
filters['metadata'], share['metadata'])
|
||||
@ -170,7 +170,7 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
|
||||
shares = self.shares_client.list_shares_with_detail(params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
shares_ids = [s["id"] for s in shares]
|
||||
for share in self.shares:
|
||||
self.assertIn(share["id"], shares_ids)
|
||||
@ -198,7 +198,7 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
|
||||
shares = self.shares_client.list_shares_with_detail(params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
for share in shares:
|
||||
st_list = self.shares_client.list_share_types()
|
||||
# find its name or id, get id
|
||||
@ -229,7 +229,7 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
|
||||
shares = self.shares_client.list_shares_with_detail(params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
for share in shares:
|
||||
self.assertEqual(filters['host'], share['host'])
|
||||
|
||||
@ -244,7 +244,7 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
|
||||
shares = self.shares_client.list_shares_with_detail(params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
for share in shares:
|
||||
self.assertEqual(
|
||||
filters['share_network_id'], share['share_network_id'])
|
||||
@ -259,7 +259,7 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
|
||||
shares = self.shares_client.list_shares_with_detail(params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
for share in shares:
|
||||
self.assertEqual(filters['snapshot_id'], share['snapshot_id'])
|
||||
self.assertFalse(self.shares[0]['id'] in [s['id'] for s in shares])
|
||||
@ -272,7 +272,7 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
|
||||
shares = self.shares_client.list_shares_with_detail(params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
sorted_list = [share['created_at'] for share in shares]
|
||||
self.assertEqual(sorted(sorted_list), sorted_list)
|
||||
|
||||
@ -295,7 +295,7 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
|
||||
# list shares by active status, at least one share is expected
|
||||
params = {"status": "available"}
|
||||
shares = self.shares_client.list_shares_with_detail(params)
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
for share in shares:
|
||||
self.assertEqual(params["status"], share["status"])
|
||||
|
||||
|
@ -21,7 +21,7 @@ from manila_tempest_tests.tests.api import base
|
||||
class AvailabilityZonesTest(base.BaseSharesTest):
|
||||
|
||||
def _list_availability_zones_assertions(self, availability_zones):
|
||||
self.assertTrue(len(availability_zones) > 0)
|
||||
self.assertGreater(len(availability_zones), 0)
|
||||
keys = ("created_at", "updated_at", "name", "id")
|
||||
for az in availability_zones:
|
||||
self.assertEqual(len(keys), len(az))
|
||||
|
@ -94,8 +94,8 @@ class ShareNetworkListMixin(object):
|
||||
for sn in listed:
|
||||
self.assertTrue(all(sn[key] == value for key, value in
|
||||
six.iteritems(valid_filter_opts)))
|
||||
self.assertTrue(sn['created_at'] <= created_before)
|
||||
self.assertTrue(sn['created_at'] >= created_since)
|
||||
self.assertLessEqual(sn['created_at'], created_before)
|
||||
self.assertGreaterEqual(sn['created_at'], created_since)
|
||||
|
||||
|
||||
class ShareNetworksTest(base.BaseSharesTest, ShareNetworkListMixin):
|
||||
|
@ -255,7 +255,7 @@ class SharesActionsTest(base.BaseSharesTest):
|
||||
shares = self.shares_client.list_shares_with_detail(params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
for share in shares:
|
||||
self.assertDictContainsSubset(
|
||||
filters['metadata'], share['metadata'])
|
||||
@ -271,7 +271,7 @@ class SharesActionsTest(base.BaseSharesTest):
|
||||
shares = self.shares_client.list_shares_with_detail(params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
for share in shares:
|
||||
self.assertEqual(filters['host'], share['host'])
|
||||
|
||||
@ -286,7 +286,7 @@ class SharesActionsTest(base.BaseSharesTest):
|
||||
shares = self.shares_client.list_shares_with_detail(params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
for share in shares:
|
||||
self.assertEqual(
|
||||
filters['share_network_id'], share['share_network_id'])
|
||||
@ -301,7 +301,7 @@ class SharesActionsTest(base.BaseSharesTest):
|
||||
shares = self.shares_client.list_shares_with_detail(params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
for share in shares:
|
||||
self.assertEqual(filters['snapshot_id'], share['snapshot_id'])
|
||||
self.assertFalse(self.shares[0]['id'] in [s['id'] for s in shares])
|
||||
@ -314,7 +314,7 @@ class SharesActionsTest(base.BaseSharesTest):
|
||||
shares = self.shares_client.list_shares_with_detail(params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
sorted_list = [share['created_at'] for share in shares]
|
||||
self.assertEqual(sorted(sorted_list), sorted_list)
|
||||
|
||||
@ -337,7 +337,7 @@ class SharesActionsTest(base.BaseSharesTest):
|
||||
# list shares by active status, at least one share is expected
|
||||
params = {"status": "available"}
|
||||
shares = self.shares_client.list_shares_with_detail(params)
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
for share in shares:
|
||||
self.assertEqual(params["status"], share["status"])
|
||||
|
||||
@ -353,7 +353,7 @@ class SharesActionsTest(base.BaseSharesTest):
|
||||
# non-admin user can get shares only from his project
|
||||
params = {"all_tenants": 1}
|
||||
shares = self.shares_client.list_shares_with_detail(params)
|
||||
self.assertTrue(len(shares) > 0)
|
||||
self.assertGreater(len(shares), 0)
|
||||
|
||||
# get share with detailed info, we need its 'project_id'
|
||||
share = self.shares_client.get_share(self.shares[0]["id"])
|
||||
@ -533,7 +533,7 @@ class SharesActionsTest(base.BaseSharesTest):
|
||||
params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(snaps) > 0)
|
||||
self.assertGreater(len(snaps), 0)
|
||||
for snap in snaps:
|
||||
self.assertEqual(filters['status'], snap['status'])
|
||||
self.assertEqual(filters['name'], snap['name'])
|
||||
@ -549,7 +549,7 @@ class SharesActionsTest(base.BaseSharesTest):
|
||||
params=filters)
|
||||
|
||||
# verify response
|
||||
self.assertTrue(len(snaps) > 0)
|
||||
self.assertGreater(len(snaps), 0)
|
||||
sorted_list = [snap['share_id'] for snap in snaps]
|
||||
self.assertEqual(sorted(sorted_list), sorted_list)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user