From ff6425bf2071e8f8589c450c53ff6f608290d5e1 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 3 Jul 2014 18:00:34 +1000 Subject: [PATCH] Implement missing mocks to remove error noise during test run Several cinder API mocks were missing from these tests. This patch adds those so the error noise reported in bug 1329391 is removed. Change-Id: Ib0ca72ff0df92d1c5187a86469ea7fc93873de11 Closes-Bug: 1329391 --- .../dashboards/admin/info/tests.py | 15 ++++++++++++--- .../dashboards/project/volumes/volumes/tests.py | 6 ++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/openstack_dashboard/dashboards/admin/info/tests.py b/openstack_dashboard/dashboards/admin/info/tests.py index 1fd14b2771..074aef0488 100644 --- a/openstack_dashboard/dashboards/admin/info/tests.py +++ b/openstack_dashboard/dashboards/admin/info/tests.py @@ -28,7 +28,7 @@ class SystemInfoViewTests(test.BaseAdminViewTests): @test.create_stubs({api.base: ('is_service_enabled',), api.nova: ('default_quota_get', 'service_list'), api.neutron: ('agent_list', 'is_extension_supported'), - api.cinder: ('default_quota_get',)}) + api.cinder: ('default_quota_get', 'service_list')}) def test_index(self): services = self.services.list() api.nova.service_list(IsA(http.HttpRequest)).AndReturn(services) @@ -41,8 +41,13 @@ class SystemInfoViewTests(test.BaseAdminViewTests): .MultipleTimes().AndReturn(True) api.nova.default_quota_get(IsA(http.HttpRequest), IgnoreArg()).AndReturn({}) + api.cinder.default_quota_get(IsA(http.HttpRequest), self.tenant.id)\ .AndReturn(self.cinder_quotas.first()) + cinder_services = self.cinder_services.list() + api.cinder.service_list(IsA(http.HttpRequest)).\ + AndReturn(cinder_services) + api.neutron.is_extension_supported(IsA(http.HttpRequest), 'security-group').AndReturn(True) @@ -70,14 +75,17 @@ class SystemInfoViewTests(test.BaseAdminViewTests): network_agents_tab._tables['network_agents'].data, [agent.__repr__() for agent in self.agents.list()] ) + self.mox.VerifyAll() @test.create_stubs({api.base: ('is_service_enabled',), - api.cinder: ('service_list', ), + api.cinder: ('default_quota_get', 'service_list'), api.nova: ('default_quota_get', 'service_list'), api.neutron: ('agent_list', 'is_extension_supported')}) def test_cinder_services_index(self): cinder_services = self.cinder_services.list() api.nova.service_list(IsA(http.HttpRequest)).AndReturn([]) + api.cinder.default_quota_get(IsA(http.HttpRequest), self.tenant.id)\ + .AndReturn(self.cinder_quotas.first()) api.cinder.service_list(IsA(http.HttpRequest)).\ AndReturn(cinder_services) api.neutron.agent_list(IsA(http.HttpRequest)).AndReturn([]) @@ -113,7 +121,7 @@ class SystemInfoViewTests(test.BaseAdminViewTests): @test.create_stubs({api.base: ('is_service_enabled',), api.nova: ('default_quota_get', 'service_list'), - api.cinder: ('default_quota_get',)}) + api.cinder: ('default_quota_get', 'service_list')}) def _test_default_quotas_index(self, neutron_enabled=True, neutron_sg_enabled=True): # Neutron does not have an API for getting default system @@ -129,6 +137,7 @@ class SystemInfoViewTests(test.BaseAdminViewTests): self.tenant.id).AndReturn(self.quotas.nova) api.cinder.default_quota_get(IsA(http.HttpRequest), self.tenant.id)\ .AndReturn(self.cinder_quotas.first()) + api.cinder.service_list(IsA(http.HttpRequest)).AndReturn([]) if neutron_enabled: self.mox.StubOutWithMock(api.neutron, 'agent_list') diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py index cdee821273..7b4f73142f 100644 --- a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py +++ b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py @@ -1040,7 +1040,7 @@ class VolumeViewTests(test.TestCase): def test_encryption_true(self): self._test_encryption(True) - @test.create_stubs({cinder: ('volume_list',), + @test.create_stubs({cinder: ('volume_list', 'volume_snapshot_list'), api.nova: ('server_list',), quotas: ('tenant_quota_usages',)}) def _test_encryption(self, encryption): @@ -1050,7 +1050,9 @@ class VolumeViewTests(test.TestCase): quota_usages = self.quota_usages.first() cinder.volume_list(IsA(http.HttpRequest), search_opts=None)\ - .AndReturn(self.volumes.list()) + .MultipleTimes().AndReturn(self.volumes.list()) + cinder.volume_list(IsA(http.HttpRequest)).AndReturn([]) + cinder.volume_snapshot_list(IsA(http.HttpRequest)).AndReturn([]) api.nova.server_list(IsA(http.HttpRequest), search_opts=None)\ .AndReturn([self.servers.list(), False]) quotas.tenant_quota_usages(IsA(http.HttpRequest))\