From 6b38fa5de7b0c47fcc7a9f5372fdd62dcd5c6bdc Mon Sep 17 00:00:00 2001 From: Charles Short Date: Fri, 20 Apr 2018 23:27:30 -0400 Subject: [PATCH] Drop mox3 from DataProcessingPluginsTests Apart of the mox3 community goal for Rocky. Change-Id: Icf53e7f582e5e386c81dac540723d97712fa3c28 Signed-off-by: Charles Short --- .../data_processing/data_plugins/tests.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sahara_dashboard/content/data_processing/data_plugins/tests.py b/sahara_dashboard/content/data_processing/data_plugins/tests.py index cb1ce807..2776ec4f 100644 --- a/sahara_dashboard/content/data_processing/data_plugins/tests.py +++ b/sahara_dashboard/content/data_processing/data_plugins/tests.py @@ -10,13 +10,13 @@ # License for the specific language governing permissions and limitations # under the License. -from django import http from django.urls import reverse -from mox3.mox import IsA # noqa +import mock import six from sahara_dashboard import api from sahara_dashboard.test import helpers as test +from sahara_dashboard.test.helpers import IsHttpRequest INDEX_URL = reverse( @@ -26,22 +26,25 @@ DETAILS_URL = reverse( class DataProcessingPluginsTests(test.TestCase): - @test.create_stubs({api.sahara: ('plugin_list',)}) + + use_mox = False + + @test.create_mocks({api.sahara: ('plugin_list',)}) def test_index(self): - api.sahara.plugin_list(IsA(http.HttpRequest)) \ - .AndReturn(self.plugins.list()) - self.mox.ReplayAll() + self.mock_plugin_list.return_value = self.plugins.list() res = self.client.get(INDEX_URL) + self.mock_plugin_list.assert_called_once_with(IsHttpRequest()) self.assertTemplateUsed(res, 'data_plugins/plugins.html') self.assertContains(res, 'vanilla') self.assertContains(res, 'plugin') - @test.create_stubs({api.sahara: ('plugin_get',)}) + @test.create_mocks({api.sahara: ('plugin_get',)}) def test_details(self): - api.sahara.plugin_get(IsA(http.HttpRequest), IsA(six.text_type)).MultipleTimes() \ - .AndReturn(self.plugins.list()[0]) - self.mox.ReplayAll() + self.mock_plugin_get.return_value = self.plugins.list()[0] res = self.client.get(DETAILS_URL) + self.assert_mock_multiple_calls_with_same_arguments( + self.mock_plugin_get, 2, mock.call(test.IsHttpRequest(), + test.IsA(six.text_type))) self.assertTemplateUsed(res, 'horizon/common/_detail.html') self.assertContains(res, 'vanilla') self.assertContains(res, 'plugin')