diff --git a/horizon/test/tests/middleware.py b/horizon/test/tests/middleware.py index b9a067ed55..c586fa0da0 100644 --- a/horizon/test/tests/middleware.py +++ b/horizon/test/tests/middleware.py @@ -131,14 +131,14 @@ class OperationLogMiddlewareTest(test.TestCase): self.assertEqual(302, resp.status_code) log_args = mock_logger.info.call_args[0] logging_str = log_args[0] % log_args[1] - self.assertTrue(request.user.username in logging_str) - self.assertTrue(self.http_referer in logging_str) - self.assertTrue(settings.LOGIN_URL in logging_str) - self.assertTrue('POST' in logging_str) - self.assertTrue('302' in logging_str) + self.assertIn(request.user.username, logging_str) + self.assertIn(self.http_referer, logging_str) + self.assertIn(settings.LOGIN_URL, logging_str) + self.assertIn('POST', logging_str) + self.assertIn('302', logging_str) post_data = ['"username": "admin"', '"password": "********"'] for data in post_data: - self.assertTrue(data in logging_str) + self.assertIn(data, logging_str) @override_settings(OPERATION_LOG_ENABLED=True) @override_settings(OPERATION_LOG_OPTIONS={'target_methods': ['GET']}) @@ -154,11 +154,11 @@ class OperationLogMiddlewareTest(test.TestCase): self.assertEqual(302, resp.status_code) log_args = mock_logger.info.call_args[0] logging_str = log_args[0] % log_args[1] - self.assertTrue(request.user.username in logging_str) - self.assertTrue(self.http_referer in logging_str) - self.assertTrue(request.path in logging_str) - self.assertTrue('GET' in logging_str) - self.assertTrue('302' in logging_str) + self.assertIn(request.user.username, logging_str) + self.assertIn(self.http_referer, logging_str) + self.assertIn(request.path, logging_str) + self.assertIn('GET', logging_str) + self.assertIn('302', logging_str) @override_settings(OPERATION_LOG_ENABLED=True) @patch(('horizon.middleware.operation_log.OperationLogMiddleware.' @@ -186,10 +186,10 @@ class OperationLogMiddlewareTest(test.TestCase): log_args = mock_logger.info.call_args[0] logging_str = log_args[0] % log_args[1] self.assertTrue(mock_logger.info.called) - self.assertTrue(request.user.username in logging_str) - self.assertTrue(self.http_referer in logging_str) - self.assertTrue(settings.LOGIN_URL in logging_str) - self.assertTrue('Unexpected error occurred.' in logging_str) + self.assertIn(request.user.username, logging_str) + self.assertIn(self.http_referer, logging_str) + self.assertIn(settings.LOGIN_URL, logging_str) + self.assertIn('Unexpected error occurred.', logging_str) post_data = ['"username": "admin"', '"password": "********"'] for data in post_data: self.assertTrue(data in logging_str) diff --git a/openstack_dashboard/dashboards/project/access_and_security/tests.py b/openstack_dashboard/dashboards/project/access_and_security/tests.py index de1a066e98..2e0af777fc 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/tests.py +++ b/openstack_dashboard/dashboards/project/access_and_security/tests.py @@ -287,8 +287,8 @@ class SecurityGroupTabTests(test.TestCase): create_action = self.getAndAssertTableAction(res, 'security_groups', 'create') - self.assertTrue('disabled' in create_action.classes, - 'The create button should be disabled') + self.assertIn('disabled', create_action.classes, + 'The create button should be disabled') def test_create_button_disabled_when_quota_exceeded_neutron_disabled(self): self._test_create_button_disabled_when_quota_exceeded(False) diff --git a/openstack_dashboard/dashboards/project/networks/tests.py b/openstack_dashboard/dashboards/project/networks/tests.py index 5c83ff834c..d74b2d6af2 100644 --- a/openstack_dashboard/dashboards/project/networks/tests.py +++ b/openstack_dashboard/dashboards/project/networks/tests.py @@ -1244,8 +1244,8 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin): self.assertItemsEqual(networks, self.networks.list()) button = find_button_fn(res) - self.assertTrue('disabled' in button.classes, - "The create button should be disabled") + self.assertIn('disabled', button.classes, + "The create button should be disabled") return button @test.create_stubs({api.neutron: ('network_list',), @@ -1327,8 +1327,8 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin): self.assertItemsEqual(subnets, self.subnets.list()) create_action = self.getAndAssertTableAction(res, 'subnets', 'create') - self.assertTrue('disabled' in create_action.classes, - 'The create button should be disabled') + self.assertIn('disabled', create_action.classes, + 'The create button should be disabled') @test.create_stubs({api.neutron: ('network_list',), quotas: ('tenant_quota_usages',)}) diff --git a/openstack_dashboard/dashboards/project/routers/tests.py b/openstack_dashboard/dashboards/project/routers/tests.py index 36022038c0..975cc7f262 100644 --- a/openstack_dashboard/dashboards/project/routers/tests.py +++ b/openstack_dashboard/dashboards/project/routers/tests.py @@ -807,8 +807,8 @@ class RouterViewTests(RouterMixin, test.TestCase): self.assertItemsEqual(routers, self.routers.list()) create_action = self.getAndAssertTableAction(res, 'routers', 'create') - self.assertTrue('disabled' in create_action.classes, - 'Create button is not disabled') + self.assertIn('disabled', create_action.classes, + 'Create button is not disabled') self.assertEqual('Create Router (Quota exceeded)', create_action.verbose_name) diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py index 778e88ba07..66c59ab1ba 100644 --- a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py +++ b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py @@ -1148,8 +1148,8 @@ class VolumeViewTests(test.TestCase): snapshot_action = self._get_volume_row_action_from_ajax( res, 'snapshots', volume.id) - self.assertTrue('disabled' in snapshot_action.classes, - 'The create snapshot button should be disabled') + self.assertIn('disabled', snapshot_action.classes, + 'The create snapshot button should be disabled') @test.create_stubs({cinder: ('tenant_absolute_limits', 'volume_list_paged', @@ -1224,8 +1224,8 @@ class VolumeViewTests(test.TestCase): self.assertItemsEqual(volumes, self.cinder_volumes.list()) create_action = self.getAndAssertTableAction(res, 'volumes', 'create') - self.assertTrue('disabled' in create_action.classes, - 'The create button should be disabled') + self.assertIn('disabled', create_action.classes, + 'The create button should be disabled') @test.create_stubs({cinder: ('tenant_absolute_limits', 'volume_get',