From 7f29364734517e4a53be84a15771d8b10d7f4b20 Mon Sep 17 00:00:00 2001 From: manchandavishal Date: Wed, 30 Mar 2022 12:10:51 +0530 Subject: [PATCH] Fixed Unit test for murano-dashboard After 7052b7f065 merged in openstack/horizon a new Unit test class introduced in horizon i.e. RestAPITestCase. This patch updates murano-dashboard to import RestAPITestCase class instead of TestCase. For more info. see [1] [1] https://review.opendev.org/c/openstack/horizon/+/827097/2/openstack_dashboard/test/helpers.py#485 Change-Id: I83c5b5a35b63790df1919974cbb4236eefd05b5d --- .zuul.yaml | 1 - muranodashboard/tests/unit/environments/test_rest_api.py | 4 ++-- muranodashboard/tests/unit/images/test_views.py | 6 +++++- muranodashboard/tests/unit/packages/test_views.py | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 9fb77f28c..a0ccb3dad 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -4,7 +4,6 @@ - horizon-non-primary-django-jobs - horizon-nodejs14-jobs - openstack-cover-jobs-horizon - - openstack-lower-constraints-jobs - openstack-python3-yoga-jobs-horizon - release-notes-jobs-python3 check: diff --git a/muranodashboard/tests/unit/environments/test_rest_api.py b/muranodashboard/tests/unit/environments/test_rest_api.py index 5518ff122..81bc383b6 100644 --- a/muranodashboard/tests/unit/environments/test_rest_api.py +++ b/muranodashboard/tests/unit/environments/test_rest_api.py @@ -28,7 +28,7 @@ PARAM_MAPPING = { @mock.patch.object(environments, 'api') @mock.patch.object(environments, 'env_api') -class TestComponentsMetadataAPI(helpers.APITestCase): +class TestComponentsMetadataAPI(helpers.RestAPITestCase): def setUp(self): super(TestComponentsMetadataAPI, self).setUp() @@ -86,7 +86,7 @@ class TestComponentsMetadataAPI(helpers.APITestCase): @mock.patch.object(environments, 'api') @mock.patch.object(environments, 'env_api') -class TestEnvironmentsMetadataApi(helpers.APITestCase): +class TestEnvironmentsMetadataApi(helpers.RestAPITestCase): def setUp(self): super(TestEnvironmentsMetadataApi, self).setUp() diff --git a/muranodashboard/tests/unit/images/test_views.py b/muranodashboard/tests/unit/images/test_views.py index b24589e52..d57ad1479 100644 --- a/muranodashboard/tests/unit/images/test_views.py +++ b/muranodashboard/tests/unit/images/test_views.py @@ -16,6 +16,7 @@ import json import unittest from unittest import mock +import horizon from horizon import exceptions from muranodashboard.images import tables @@ -161,9 +162,12 @@ class TestMarkedImagesView(unittest.TestCase): @mock.patch.object(views, 'reverse', autospec=True) @mock.patch.object(views, 'glance', autospec=True) - def test_get_data_except_glance_image_list_exception(self, mock_glance, + @mock.patch.object(horizon.messages, 'horizon_message_already_queued') + def test_get_data_except_glance_image_list_exception(self, mock_messages, + mock_glance, mock_reverse): """Test that glance_v1_client.images.list exception is handled.""" + mock_messages.return_value = True mock_glance_client = mock.Mock() mock_glance_client.images.list.side_effect = Exception() mock_glance.glanceclient.return_value = mock_glance_client diff --git a/muranodashboard/tests/unit/packages/test_views.py b/muranodashboard/tests/unit/packages/test_views.py index 33d09ff84..32c798991 100644 --- a/muranodashboard/tests/unit/packages/test_views.py +++ b/muranodashboard/tests/unit/packages/test_views.py @@ -130,7 +130,7 @@ class TestDetailView(helpers.APITestCase): redirect='test_redirect') -class TestModifyPackageView(helpers.APITestCase): +class TestModifyPackageView(helpers.RestAPITestCase): def setUp(self): super(TestModifyPackageView, self).setUp() @@ -783,7 +783,7 @@ class TestImportPackageWizard(helpers.APITestCase): 'package': 'test_package'}, kwargs) -class TestImportBundleWizard(helpers.APITestCase): +class TestImportBundleWizard(helpers.RestAPITestCase): def setUp(self): super(TestImportBundleWizard, self).setUp()