Merge "Modify use of assertTrue(A in B)"
This commit is contained in:
commit
b50d63110f
@ -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."""
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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,
|
||||
|
@ -159,7 +159,7 @@ class AvailabilityZoneMigrationChecks(BaseMigrationChecks):
|
||||
|
||||
for az in engine.execute(az_table.select()):
|
||||
self.test_case.assertTrue(uuidutils.is_uuid_like(az.id))
|
||||
self.test_case.assertTrue(az.name in self.valid_az_names)
|
||||
self.test_case.assertIn(az.name, self.valid_az_names)
|
||||
self.test_case.assertEqual('False', az.deleted)
|
||||
|
||||
services_table = utils.load_table('services', engine)
|
||||
|
@ -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},
|
||||
@ -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))
|
||||
|
||||
@ -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):
|
||||
|
||||
|
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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):
|
||||
|
@ -173,7 +173,7 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
|
||||
self.assertTrue(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
|
||||
@ -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)
|
||||
|
||||
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
|
||||
def test_list_shares_with_detail_filter_by_host(self):
|
||||
|
@ -337,11 +337,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