Use assert(Not)In/Greater(Equal)/LessEqual/IsNotNone
Instead of using assertTrue(A * B) / assertFalse(A * B) developers should use assertNotIn, assertIn, assertGreater, assertGreaterEqual or assertLessEqual or assertIsNotNone. They are compatible with Python 2.7[1] and 3.4[2] [1]: https://docs.python.org/2.7/library/unittest.html [2]: https://docs.python.org/3.4/library/unittest.html Change-Id: I26ab3bc3cad5e1dddc812388b864d51c73f53f58
This commit is contained in:
parent
297d8bef3b
commit
f33ac181b0
@ -90,7 +90,7 @@ class TestFaults(test.TestCase):
|
||||
resp = req.get_response(raiser)
|
||||
self.assertEqual("application/json", resp.content_type)
|
||||
self.assertEqual(404, resp.status_int)
|
||||
self.assertTrue(six.b('whut?') in resp.body)
|
||||
self.assertIn(six.b('whut?'), resp.body)
|
||||
|
||||
def test_raise_403(self):
|
||||
"""Ensure the ability to raise :class:`Fault` in WSGI-ified methods."""
|
||||
@ -102,8 +102,8 @@ class TestFaults(test.TestCase):
|
||||
resp = req.get_response(raiser)
|
||||
self.assertEqual("application/json", resp.content_type)
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertTrue(six.b('resizeNotAllowed') not in resp.body)
|
||||
self.assertTrue(six.b('forbidden') in resp.body)
|
||||
self.assertNotIn(six.b('resizeNotAllowed'), resp.body)
|
||||
self.assertIn(six.b('forbidden'), resp.body)
|
||||
|
||||
def test_fault_has_status_int(self):
|
||||
"""Ensure the status_int is set correctly on faults."""
|
||||
|
@ -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):
|
||||
|
||||
|
@ -293,7 +293,7 @@ class LimitMiddlewareTest(BaseLimitTestSuite):
|
||||
response = request.get_response(self.app)
|
||||
self.assertEqual(413, response.status_int)
|
||||
|
||||
self.assertTrue('Retry-After' in response.headers)
|
||||
self.assertIn('Retry-After', response.headers)
|
||||
retry_after = int(response.headers['Retry-After'])
|
||||
self.assertAlmostEqual(retry_after, 60, 1)
|
||||
|
||||
|
@ -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'},
|
||||
|
@ -80,10 +80,10 @@ class AvailabilityZonesAPITest(test.TestCase):
|
||||
self.assertEqual(["availability_zones"], list(result.keys()))
|
||||
self.assertIsInstance(result["availability_zones"], list)
|
||||
self.assertEqual(2, len(result["availability_zones"]))
|
||||
self.assertTrue(azs[0] in result["availability_zones"])
|
||||
self.assertIn(azs[0], result["availability_zones"])
|
||||
azs[1].pop("deleted")
|
||||
azs[1].pop("redundant_key")
|
||||
self.assertTrue(azs[1] in result["availability_zones"])
|
||||
self.assertIn(azs[1], result["availability_zones"])
|
||||
|
||||
@ddt.data(
|
||||
('1.0', availability_zones.AvailabilityZoneController),
|
||||
|
@ -283,7 +283,7 @@ class CGSnapshotApiTest(test.TestCase):
|
||||
exc = self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update,
|
||||
self.request, 'fake_id', body)
|
||||
self.assertTrue('unknown_field' in six.text_type(exc))
|
||||
self.assertIn('unknown_field', six.text_type(exc))
|
||||
self.mock_policy_check.assert_called_once_with(
|
||||
self.context, self.resource_name, 'update')
|
||||
|
||||
@ -292,7 +292,7 @@ class CGSnapshotApiTest(test.TestCase):
|
||||
exc = self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update,
|
||||
self.request, 'fake_id', body)
|
||||
self.assertTrue('created_at' in six.text_type(exc))
|
||||
self.assertIn('created_at', six.text_type(exc))
|
||||
self.mock_policy_check.assert_called_once_with(
|
||||
self.context, self.resource_name, 'update')
|
||||
|
||||
|
@ -388,7 +388,7 @@ class CGApiTest(test.TestCase):
|
||||
exc = self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
self.request, body)
|
||||
self.assertTrue('unknown_field' in six.text_type(exc))
|
||||
self.assertIn('unknown_field', six.text_type(exc))
|
||||
self.mock_policy_check.assert_called_once_with(
|
||||
self.context, self.resource_name, 'create')
|
||||
|
||||
@ -452,7 +452,7 @@ class CGApiTest(test.TestCase):
|
||||
exc = self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update,
|
||||
self.request, 'fake_id', body)
|
||||
self.assertTrue('unknown_field' in six.text_type(exc))
|
||||
self.assertIn('unknown_field', six.text_type(exc))
|
||||
self.mock_policy_check.assert_called_once_with(
|
||||
self.context, self.resource_name, 'update')
|
||||
|
||||
@ -461,7 +461,7 @@ class CGApiTest(test.TestCase):
|
||||
exc = self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update,
|
||||
self.request, 'fake_id', body)
|
||||
self.assertTrue('share_types' in six.text_type(exc))
|
||||
self.assertIn('share_types', six.text_type(exc))
|
||||
self.mock_policy_check.assert_called_once_with(
|
||||
self.context, self.resource_name, 'update')
|
||||
|
||||
|
@ -152,7 +152,7 @@ class ShareTypesAPITest(test.TestCase):
|
||||
self.assertEqual('value1', entry['extra_specs'].get('key1'))
|
||||
else:
|
||||
self.assertIsNone(entry['extra_specs'].get('key1'))
|
||||
self.assertTrue('required_extra_specs' in entry)
|
||||
self.assertIn('required_extra_specs', entry)
|
||||
required_extra_spec = entry['required_extra_specs'].get(
|
||||
constants.ExtraSpecs.DRIVER_HANDLES_SHARE_SERVERS, '')
|
||||
self.assertEqual('true', required_extra_spec)
|
||||
@ -290,7 +290,7 @@ class ShareTypesAPITest(test.TestCase):
|
||||
@ddt.data(None, True, 'true', 'false', 'all')
|
||||
def test_parse_is_public_valid(self, value):
|
||||
result = self.controller._parse_is_public(value)
|
||||
self.assertTrue(result in (True, False, None))
|
||||
self.assertIn(result, (True, False, None))
|
||||
|
||||
def test_parse_is_public_invalid(self):
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
|
@ -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(*)
|
||||
|
@ -262,7 +262,7 @@ class ShareDatabaseAPITestCase(test.TestCase):
|
||||
|
||||
db_share = db_api.share_get(self.ctxt, share['id'])
|
||||
|
||||
self.assertTrue('has_replicas' in db_share)
|
||||
self.assertIn('has_replicas', db_share)
|
||||
|
||||
@ddt.data({'with_share_data': False, 'with_share_server': False},
|
||||
{'with_share_data': False, 'with_share_server': True},
|
||||
@ -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()))
|
||||
|
||||
@ -922,7 +922,7 @@ class ShareSnapshotDatabaseAPITestCase(test.TestCase):
|
||||
|
||||
for instance in instances:
|
||||
self.assertEqual('fake_snapshot_id_1', instance['snapshot_id'])
|
||||
self.assertTrue(instance['status'] in filters['statuses'])
|
||||
self.assertIn(instance['status'], filters['statuses'])
|
||||
|
||||
self.assertEqual(expected_number, len(instances))
|
||||
|
||||
@ -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'])
|
||||
@ -1979,7 +1979,7 @@ class ShareServerDatabaseAPITestCase(test.TestCase):
|
||||
self.assertEqual(values['host'], server.host)
|
||||
self.assertEqual(values['status'], server.status)
|
||||
self.assertDictMatch(server['backend_details'], details)
|
||||
self.assertTrue('backend_details' in server.to_dict())
|
||||
self.assertIn('backend_details', server.to_dict())
|
||||
|
||||
def test_delete_with_details(self):
|
||||
server = db_utils.create_share_server(backend_details={
|
||||
|
@ -58,7 +58,7 @@ class FilterSchedulerTestCase(test_base.SchedulerTestCase):
|
||||
retval = sched._format_filter_properties(
|
||||
fake_context, {}, request_spec)
|
||||
|
||||
self.assertTrue('replication_domain' in retval[0])
|
||||
self.assertIn('replication_domain', retval[0])
|
||||
|
||||
def test_create_share_no_hosts(self):
|
||||
# Ensure empty hosts/child_zones result in NoValidHosts exception.
|
||||
|
@ -51,6 +51,6 @@ class HostFiltersTestCase(test.TestCase):
|
||||
|
||||
def test_all_filters(self):
|
||||
# Double check at least a couple of known filters exist
|
||||
self.assertTrue('JsonFilter' in self.class_map)
|
||||
self.assertTrue('CapabilitiesFilter' in self.class_map)
|
||||
self.assertTrue('AvailabilityZoneFilter' in self.class_map)
|
||||
self.assertIn('JsonFilter', self.class_map)
|
||||
self.assertIn('CapabilitiesFilter', self.class_map)
|
||||
self.assertIn('AvailabilityZoneFilter', self.class_map)
|
||||
|
@ -28,9 +28,9 @@ class TestWeightHandler(test.TestCase):
|
||||
handler = base.BaseWeightHandler(
|
||||
base.BaseWeigher, namespace)
|
||||
classes = handler.get_all_classes()
|
||||
self.assertTrue(fakes.FakeWeigher1 in classes)
|
||||
self.assertTrue(fakes.FakeWeigher2 in classes)
|
||||
self.assertFalse(fakes.FakeClass in classes)
|
||||
self.assertIn(fakes.FakeWeigher1, classes)
|
||||
self.assertIn(fakes.FakeWeigher2, classes)
|
||||
self.assertNotIn(fakes.FakeClass, classes)
|
||||
|
||||
def test_no_multiplier(self):
|
||||
class FakeWeigher(base.BaseWeigher):
|
||||
|
@ -328,7 +328,7 @@ class IsilonTest(test.TestCase):
|
||||
self.assertEqual('PUT', action)
|
||||
self.assertEqual(expected_url, url)
|
||||
self.assertEqual(1, len(kwargs))
|
||||
self.assertTrue('data' in kwargs)
|
||||
self.assertIn('data', kwargs)
|
||||
actual_clients = set(kwargs['data']['clients'])
|
||||
expected_clients = set(existing_ips)
|
||||
expected_clients.add(new_allowed_ip)
|
||||
@ -368,7 +368,7 @@ class IsilonTest(test.TestCase):
|
||||
self.assertEqual('PUT', action)
|
||||
self.assertEqual(expected_url, url)
|
||||
self.assertEqual(1, len(kwargs))
|
||||
self.assertTrue('data' in kwargs)
|
||||
self.assertIn('data', kwargs)
|
||||
actual_clients = set(kwargs['data']['host_acl'])
|
||||
expected_clients = set(existing_ips)
|
||||
expected_clients.add('allow:' + new_allowed_ip)
|
||||
|
@ -852,7 +852,7 @@ class IsilonApiTest(test.TestCase):
|
||||
expected_url = '{0}/namespace{1}?recursive={2}'.format(
|
||||
self._mock_url, path, six.text_type(is_recursive))
|
||||
self.assertEqual(expected_url, request.url)
|
||||
self.assertTrue("x-isi-ifs-target-type" in request.headers)
|
||||
self.assertIn("x-isi-ifs-target-type", request.headers)
|
||||
self.assertEqual("container",
|
||||
request.headers['x-isi-ifs-target-type'])
|
||||
|
||||
@ -863,6 +863,6 @@ class IsilonApiTest(test.TestCase):
|
||||
self._mock_url, fq_dest_path, snapshot_name
|
||||
)
|
||||
self.assertEqual(expected_url, request.request.url)
|
||||
self.assertTrue("x-isi-ifs-copy-source" in request.headers)
|
||||
self.assertIn("x-isi-ifs-copy-source", request.headers)
|
||||
self.assertEqual('/namespace' + fq_file_path,
|
||||
request.headers['x-isi-ifs-copy-source'])
|
||||
|
@ -62,7 +62,7 @@ class StorageObjectManagerTestCase(test.TestCase):
|
||||
isinstance(self.manager.getStorageContext(key), value))
|
||||
|
||||
for key in self.manager.context.keys():
|
||||
self.assertTrue(key in type_map)
|
||||
self.assertIn(key, type_map)
|
||||
|
||||
def test_get_storage_context_invalid_type(self):
|
||||
|
||||
|
@ -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):
|
||||
@ -832,8 +832,8 @@ class ShareManagerTestCase(test.TestCase):
|
||||
self.assertEqual(2, len(r_ids))
|
||||
if has_snapshots:
|
||||
for snapshot_dict in snapshot_list_arg:
|
||||
self.assertTrue('active_replica_snapshot' in snapshot_dict)
|
||||
self.assertTrue('share_replica_snapshot' in snapshot_dict)
|
||||
self.assertIn('active_replica_snapshot', snapshot_dict)
|
||||
self.assertIn('share_replica_snapshot', snapshot_dict)
|
||||
else:
|
||||
self.assertFalse(mock_instance_get_call.called)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -1336,8 +1336,8 @@ class ShareManagerTestCase(test.TestCase):
|
||||
self.assertEqual(0, mock_warning_log.call_count)
|
||||
self.assertTrue(mock_driver_call.called)
|
||||
snapshot_list_arg = mock_driver_call.call_args[0][4]
|
||||
self.assertTrue('active_replica_snapshot' in snapshot_list_arg[0])
|
||||
self.assertTrue('share_replica_snapshot' in snapshot_list_arg[0])
|
||||
self.assertIn('active_replica_snapshot', snapshot_list_arg[0])
|
||||
self.assertIn('share_replica_snapshot', snapshot_list_arg[0])
|
||||
mock_db_update_call.assert_has_calls(mock_db_update_calls)
|
||||
self.assertEqual(1, mock_debug_log.call_count)
|
||||
|
||||
@ -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'])
|
||||
|
||||
|
@ -65,7 +65,7 @@ class ShareRpcAPITestCase(test.TestCase):
|
||||
self.rpcapi = share_rpcapi.ShareAPI()
|
||||
|
||||
def test_serialized_share_has_id(self):
|
||||
self.assertTrue('id' in self.fake_share)
|
||||
self.assertIn('id', self.fake_share)
|
||||
|
||||
def _test_share_api(self, method, rpc_method, **kwargs):
|
||||
expected_retval = 'foo' if method == 'call' else None
|
||||
|
@ -28,8 +28,8 @@ class ContextTestCase(test.TestCase):
|
||||
admin_context = user_context.elevated()
|
||||
self.assertFalse(user_context.is_admin)
|
||||
self.assertTrue(admin_context.is_admin)
|
||||
self.assertFalse('admin' in user_context.roles)
|
||||
self.assertTrue('admin' in admin_context.roles)
|
||||
self.assertNotIn('admin', user_context.roles)
|
||||
self.assertIn('admin', admin_context.roles)
|
||||
|
||||
def test_request_context_sets_is_admin(self):
|
||||
ctxt = context.RequestContext('111',
|
||||
|
@ -428,20 +428,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):
|
||||
|
@ -301,7 +301,7 @@ class ExceptionTest(test.TestCase):
|
||||
|
||||
if hasattr(exception_type, 'headers'):
|
||||
for (key, value) in exception_type.headers.items():
|
||||
self.assertTrue(key in resp.headers)
|
||||
self.assertIn(key, resp.headers)
|
||||
self.assertEqual(value, resp.headers[key])
|
||||
|
||||
def test_quota_error_mapping(self):
|
||||
|
@ -53,7 +53,7 @@ class ShareServersAdminTest(base.BaseSharesAdminTest):
|
||||
@test.attr(type=[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,10 +170,10 @@ 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.assertTrue(share["id"] in shares_ids)
|
||||
self.assertIn(share["id"], shares_ids)
|
||||
for share in shares:
|
||||
# find its name or id, get id
|
||||
st_id = None
|
||||
@ -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
|
||||
@ -218,7 +218,7 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
|
||||
filters['share_type_id'], st_id)
|
||||
share_ids = [share['id'] for share in shares]
|
||||
for share in self.shares:
|
||||
self.assertTrue(share['id'] in share_ids)
|
||||
self.assertIn(share['id'], share_ids)
|
||||
|
||||
@test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND])
|
||||
def test_list_shares_with_detail_filter_by_host(self):
|
||||
@ -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)
|
||||
|
||||
|
@ -340,11 +340,11 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
|
||||
|
||||
self.umount_share(ssh_client)
|
||||
|
||||
self.assertTrue('1m1.bin' in output)
|
||||
self.assertTrue('1m2.bin' in output)
|
||||
self.assertTrue('1m3.bin' in output)
|
||||
self.assertTrue('1m4.bin' in output)
|
||||
self.assertTrue('1m5.bin' in output)
|
||||
self.assertIn('1m1.bin', output)
|
||||
self.assertIn('1m2.bin', output)
|
||||
self.assertIn('1m3.bin', output)
|
||||
self.assertIn('1m4.bin', output)
|
||||
self.assertIn('1m5.bin', output)
|
||||
|
||||
|
||||
class TestShareBasicOpsNFS(ShareBasicOpsBase):
|
||||
|
Loading…
Reference in New Issue
Block a user