From 4b304f8b20085ec5d572d73ff2379a189fd77022 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Sat, 31 Mar 2018 21:00:17 +0900 Subject: [PATCH] Remove remaining mox usage in tests converted to mock Some mox dependencies were remaining in the unit tests converted into mock. Part of blueprint mock-framework-in-unit-tests Change-Id: I768c645b8d11fd75dbbcabc7ab8170b6b1074664 Signed-off-by: Akihiro Motoki --- .../dashboards/admin/hypervisors/compute/tests.py | 2 +- .../dashboards/admin/metadata_defs/tests.py | 13 ++++++------- .../dashboards/project/networks/tests.py | 4 ---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/openstack_dashboard/dashboards/admin/hypervisors/compute/tests.py b/openstack_dashboard/dashboards/admin/hypervisors/compute/tests.py index 514d080e6d..42f2ce44ba 100644 --- a/openstack_dashboard/dashboards/admin/hypervisors/compute/tests.py +++ b/openstack_dashboard/dashboards/admin/hypervisors/compute/tests.py @@ -101,7 +101,7 @@ class MigrateHostViewTest(test.BaseAdminViewTests): if service.binary == 'nova-compute' and service.status == 'disabled'] disabled_service = disabled_services[0] - self.mox.ReplayAll() + url = reverse('horizon:admin:hypervisors:compute:migrate_host', args=[disabled_service.host]) res = self.client.get(url) diff --git a/openstack_dashboard/dashboards/admin/metadata_defs/tests.py b/openstack_dashboard/dashboards/admin/metadata_defs/tests.py index e4d38c9878..59a3169826 100644 --- a/openstack_dashboard/dashboards/admin/metadata_defs/tests.py +++ b/openstack_dashboard/dashboards/admin/metadata_defs/tests.py @@ -30,13 +30,13 @@ from openstack_dashboard.test import helpers as test class MetadataDefinitionsView(test.BaseAdminViewTests): def test_namespace_object(self): - mock = self.mox.CreateMockAnything() - mock.name = 'hello' - mock.description = 'world' - mock.visibility = 'public' - mock.resource_type_associations = [{'name': 'sample'}] + ns_obj = mock.Mock() + ns_obj.name = 'hello' + ns_obj.description = 'world' + ns_obj.visibility = 'public' + ns_obj.resource_type_associations = [{'name': 'sample'}] - namespace = api.glance.Namespace(mock) + namespace = api.glance.Namespace(ns_obj) self.assertEqual('world', namespace.description) self.assertTrue(namespace.public) self.assertEqual('sample', namespace.resource_type_names[0]) @@ -235,7 +235,6 @@ class MetadataDefinitionsCreateViewTest(test.BaseAdminViewTests): "protected": False, } - self.mox.ReplayAll() mock_metadefs_namespace_create.return_value = metadata form_data = { diff --git a/openstack_dashboard/dashboards/project/networks/tests.py b/openstack_dashboard/dashboards/project/networks/tests.py index 57619c7712..97366073a1 100644 --- a/openstack_dashboard/dashboards/project/networks/tests.py +++ b/openstack_dashboard/dashboards/project/networks/tests.py @@ -924,8 +924,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin): network = self.networks.first() self.mock_network_get.side_effect = self.exceptions.neutron - self.mox.ReplayAll() - url = reverse('horizon:project:networks:update', args=[network.id]) res = self.client.get(url) @@ -990,8 +988,6 @@ class NetworkTests(test.TestCase, NetworkStubMixin): self._stub_net_list() self.mock_network_delete.return_value = None - self.mox.ReplayAll() - form_data = {'action': 'networks__delete__%s' % network.id} res = self.client.post(INDEX_URL, form_data) self.assertRedirectsNoFollow(res, INDEX_URL)