diff --git a/manila/tests/api/middleware/test_faults.py b/manila/tests/api/middleware/test_faults.py index 44874974a8..a540187e72 100644 --- a/manila/tests/api/middleware/test_faults.py +++ b/manila/tests/api/middleware/test_faults.py @@ -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.""" diff --git a/manila/tests/api/v1/test_limits.py b/manila/tests/api/v1/test_limits.py index 1323982fa1..ecf45b72b6 100644 --- a/manila/tests/api/v1/test_limits.py +++ b/manila/tests/api/v1/test_limits.py @@ -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) diff --git a/manila/tests/api/v2/test_availability_zones.py b/manila/tests/api/v2/test_availability_zones.py index 60f1441a38..9e9cf767ac 100644 --- a/manila/tests/api/v2/test_availability_zones.py +++ b/manila/tests/api/v2/test_availability_zones.py @@ -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), diff --git a/manila/tests/api/v2/test_cgsnapshots.py b/manila/tests/api/v2/test_cgsnapshots.py index 4c609c98d3..79b8b7ed03 100644 --- a/manila/tests/api/v2/test_cgsnapshots.py +++ b/manila/tests/api/v2/test_cgsnapshots.py @@ -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') diff --git a/manila/tests/api/v2/test_consistency_groups.py b/manila/tests/api/v2/test_consistency_groups.py index 7b761cc590..d0360f0a5b 100644 --- a/manila/tests/api/v2/test_consistency_groups.py +++ b/manila/tests/api/v2/test_consistency_groups.py @@ -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') diff --git a/manila/tests/api/v2/test_share_types.py b/manila/tests/api/v2/test_share_types.py index 75d1dc411c..ef0750344e 100644 --- a/manila/tests/api/v2/test_share_types.py +++ b/manila/tests/api/v2/test_share_types.py @@ -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, diff --git a/manila/tests/db/migrations/alembic/migrations_data_checks.py b/manila/tests/db/migrations/alembic/migrations_data_checks.py index 217d07587b..2e6d9b0957 100644 --- a/manila/tests/db/migrations/alembic/migrations_data_checks.py +++ b/manila/tests/db/migrations/alembic/migrations_data_checks.py @@ -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) diff --git a/manila/tests/db/sqlalchemy/test_api.py b/manila/tests/db/sqlalchemy/test_api.py index 40ee8197e4..0a05bee130 100644 --- a/manila/tests/db/sqlalchemy/test_api.py +++ b/manila/tests/db/sqlalchemy/test_api.py @@ -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={ diff --git a/manila/tests/scheduler/drivers/test_filter.py b/manila/tests/scheduler/drivers/test_filter.py index 0a62630116..d365bfe2ac 100644 --- a/manila/tests/scheduler/drivers/test_filter.py +++ b/manila/tests/scheduler/drivers/test_filter.py @@ -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. diff --git a/manila/tests/scheduler/filters/test_base_host.py b/manila/tests/scheduler/filters/test_base_host.py index cf51d293ef..132a47074f 100644 --- a/manila/tests/scheduler/filters/test_base_host.py +++ b/manila/tests/scheduler/filters/test_base_host.py @@ -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) diff --git a/manila/tests/scheduler/weighers/test_base.py b/manila/tests/scheduler/weighers/test_base.py index b09c596171..80c0ed53e9 100644 --- a/manila/tests/scheduler/weighers/test_base.py +++ b/manila/tests/scheduler/weighers/test_base.py @@ -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): diff --git a/manila/tests/share/drivers/emc/plugins/isilon/test_isilon.py b/manila/tests/share/drivers/emc/plugins/isilon/test_isilon.py index deefb789ef..5e340c6759 100644 --- a/manila/tests/share/drivers/emc/plugins/isilon/test_isilon.py +++ b/manila/tests/share/drivers/emc/plugins/isilon/test_isilon.py @@ -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) diff --git a/manila/tests/share/drivers/emc/plugins/isilon/test_isilon_api.py b/manila/tests/share/drivers/emc/plugins/isilon/test_isilon_api.py index e073a3d9b5..a8fc894390 100644 --- a/manila/tests/share/drivers/emc/plugins/isilon/test_isilon_api.py +++ b/manila/tests/share/drivers/emc/plugins/isilon/test_isilon_api.py @@ -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']) diff --git a/manila/tests/share/drivers/emc/plugins/vnx/test_object_manager.py b/manila/tests/share/drivers/emc/plugins/vnx/test_object_manager.py index 28b1ce7603..77ec0a991c 100644 --- a/manila/tests/share/drivers/emc/plugins/vnx/test_object_manager.py +++ b/manila/tests/share/drivers/emc/plugins/vnx/test_object_manager.py @@ -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): diff --git a/manila/tests/share/test_manager.py b/manila/tests/share/test_manager.py index c4adf3a6aa..9322a3f943 100644 --- a/manila/tests/share/test_manager.py +++ b/manila/tests/share/test_manager.py @@ -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) diff --git a/manila/tests/share/test_rpcapi.py b/manila/tests/share/test_rpcapi.py index 947591e713..c63c21cc73 100644 --- a/manila/tests/share/test_rpcapi.py +++ b/manila/tests/share/test_rpcapi.py @@ -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 diff --git a/manila/tests/test_context.py b/manila/tests/test_context.py index 017a06846c..c7e8272e38 100644 --- a/manila/tests/test_context.py +++ b/manila/tests/test_context.py @@ -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', diff --git a/manila/tests/test_wsgi.py b/manila/tests/test_wsgi.py index 75da3b6eb3..05789a2d8f 100644 --- a/manila/tests/test_wsgi.py +++ b/manila/tests/test_wsgi.py @@ -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): diff --git a/manila_tempest_tests/tests/api/admin/test_shares_actions.py b/manila_tempest_tests/tests/api/admin/test_shares_actions.py index 1e638eb6a9..72edd6b1f3 100644 --- a/manila_tempest_tests/tests/api/admin/test_shares_actions.py +++ b/manila_tempest_tests/tests/api/admin/test_shares_actions.py @@ -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): diff --git a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py index 34c9c556db..0e2e390664 100644 --- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py +++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py @@ -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):