From 51378f7058e8b7a0d7656f2c21ea1c807e84469b Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Mon, 8 Jan 2018 06:52:15 +0900 Subject: [PATCH] Minor fix on mock migrated tests Part of blueprint mock-framework-in-unit-tests Change-Id: I40d18633889819e3087842e4fa9c7eccc2619c72 --- .../dashboards/project/images/images/tests.py | 2 +- .../dashboards/project/images/tests.py | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/openstack_dashboard/dashboards/project/images/images/tests.py b/openstack_dashboard/dashboards/project/images/images/tests.py index df7611c8db..0155ae8622 100644 --- a/openstack_dashboard/dashboards/project/images/images/tests.py +++ b/openstack_dashboard/dashboards/project/images/images/tests.py @@ -540,7 +540,7 @@ class ImageViewTests(test.ResetImageAPIVersionMixin, test.TestCase): class OwnerFilterTests(test.TestCase): def setUp(self): super(OwnerFilterTests, self).setUp() - self.table = mock.Mock(sppec=horizon_tables.DataTable) + self.table = mock.Mock(spec=horizon_tables.DataTable) self.table.request = self.request @override_settings(IMAGES_LIST_FILTER_TENANTS=[{'name': 'Official', diff --git a/openstack_dashboard/dashboards/project/images/tests.py b/openstack_dashboard/dashboards/project/images/tests.py index 6e857215ba..f618f78fc6 100644 --- a/openstack_dashboard/dashboards/project/images/tests.py +++ b/openstack_dashboard/dashboards/project/images/tests.py @@ -261,7 +261,7 @@ class ImagesAndSnapshotsUtilsTests(BaseImagesTestCase): self.exceptions.glance, [private_images, False, False], [shared_images, False, False], - ] + ] images_cache = {} ret = utils.get_available_images(self.request, self.tenant.id, @@ -275,11 +275,9 @@ class ImagesAndSnapshotsUtilsTests(BaseImagesTestCase): filters={'visibility': 'shared', 'status': 'active'}) ] self.mock_image_list.assert_has_calls(image_calls) - handle_calls = [ - mock.call(test.IsHttpRequest(), - "Unable to retrieve public images."), - ] - mock_exception_handle.assert_has_calls(handle_calls) + mock_exception_handle.assert_called_once_with( + test.IsHttpRequest(), + "Unable to retrieve public images.") expected_images = [image for image in private_images if image.container_format not in ('ami', 'aki')] @@ -352,11 +350,9 @@ class ImagesAndSnapshotsUtilsTests(BaseImagesTestCase): filters={'status': 'active', 'property-owner_id': '1'}) ] self.mock_image_list.assert_has_calls(image_calls) - handle_calls = [ - mock.call(test.IsHttpRequest(), - "Unable to retrieve images for the current project."), - ] - mock_exception_handle.assert_has_calls(handle_calls) + mock_exception_handle.assert_called_once_with( + test.IsHttpRequest(), + "Unable to retrieve images for the current project.") class SeleniumTests(test.SeleniumTestCase):