diff --git a/openstack_dashboard/dashboards/project/volumes/backups/tests.py b/openstack_dashboard/dashboards/project/volumes/backups/tests.py index 2fc4c61638..ffd069b6f5 100644 --- a/openstack_dashboard/dashboards/project/volumes/backups/tests.py +++ b/openstack_dashboard/dashboards/project/volumes/backups/tests.py @@ -52,13 +52,10 @@ class VolumeBackupsViewTests(test.TestCase): self.assertMessageCount(error=0, warning=0) self.assertRedirectsNoFollow(res, VOLUME_BACKUPS_TAB_URL) - @test.create_stubs({api.nova: ('server_list',), - api.cinder: ('volume_snapshot_list', - 'volume_list', + @test.create_stubs({api.cinder: ('volume_list', 'volume_backup_supported', 'volume_backup_list', - 'volume_backup_delete', - 'tenant_absolute_limits')}) + 'volume_backup_delete')}) def test_delete_volume_backup(self): vol_backups = self.cinder_volume_backups.list() volumes = self.cinder_volumes.list() @@ -72,20 +69,10 @@ class VolumeBackupsViewTests(test.TestCase): AndReturn(volumes) api.cinder.volume_backup_delete(IsA(http.HttpRequest), backup.id) - api.cinder.volume_list(IsA(http.HttpRequest), search_opts=None). \ - AndReturn(volumes) - api.nova.server_list(IsA(http.HttpRequest), search_opts=None). \ - AndReturn([self.servers.list(), False]) - api.cinder.volume_snapshot_list(IsA(http.HttpRequest)). \ - AndReturn([]) - api.cinder.volume_list(IsA(http.HttpRequest)). \ - AndReturn(volumes) api.cinder.volume_backup_list(IsA(http.HttpRequest)). \ AndReturn(vol_backups) api.cinder.volume_list(IsA(http.HttpRequest)). \ AndReturn(volumes) - api.cinder.tenant_absolute_limits(IsA(http.HttpRequest))\ - .MultipleTimes().AndReturn(self.cinder_limits['absolute']) self.mox.ReplayAll() formData = {'action': diff --git a/openstack_dashboard/dashboards/project/volumes/snapshots/tests.py b/openstack_dashboard/dashboards/project/volumes/snapshots/tests.py index 26e6d66953..25a948aeb7 100644 --- a/openstack_dashboard/dashboards/project/volumes/snapshots/tests.py +++ b/openstack_dashboard/dashboards/project/volumes/snapshots/tests.py @@ -105,17 +105,13 @@ class VolumeSnapshotsViewTests(test.TestCase): res = self.client.post(url, formData) self.assertRedirectsNoFollow(res, VOLUME_SNAPSHOTS_TAB_URL) - @test.create_stubs({api.nova: ('server_list',), - api.cinder: ('tenant_absolute_limits', - 'volume_snapshot_list', + @test.create_stubs({api.cinder: ('volume_snapshot_list', 'volume_list', 'volume_backup_supported', - 'volume_backup_list', 'volume_snapshot_delete')}) def test_delete_volume_snapshot(self): vol_snapshots = self.cinder_volume_snapshots.list() volumes = self.cinder_volumes.list() - vol_backups = self.cinder_volume_backups.list() snapshot = self.cinder_volume_snapshots.first() api.cinder.volume_backup_supported(IsA(http.HttpRequest)). \ @@ -126,25 +122,15 @@ class VolumeSnapshotsViewTests(test.TestCase): AndReturn(volumes) api.cinder.volume_snapshot_delete(IsA(http.HttpRequest), snapshot.id) - api.cinder.volume_list(IsA(http.HttpRequest), search_opts=None). \ - AndReturn(volumes) - api.nova.server_list(IsA(http.HttpRequest), search_opts=None). \ - AndReturn([self.servers.list(), False]) api.cinder.volume_snapshot_list(IsA(http.HttpRequest)). \ AndReturn([]) api.cinder.volume_list(IsA(http.HttpRequest)). \ AndReturn(volumes) - api.cinder.volume_backup_list(IsA(http.HttpRequest)). \ - AndReturn(vol_backups) - api.cinder.volume_list(IsA(http.HttpRequest)). \ - AndReturn(volumes) - api.cinder.tenant_absolute_limits(IsA(http.HttpRequest)).MultipleTimes(). \ - AndReturn(self.cinder_limits['absolute']) self.mox.ReplayAll() formData = {'action': 'volume_snapshots__delete__%s' % snapshot.id} - res = self.client.post(INDEX_URL, formData, follow=True) + res = self.client.post(VOLUME_SNAPSHOTS_TAB_URL, formData, follow=True) self.assertIn("Scheduled deletion of Volume Snapshot: test snapshot", [m.message for m in res.context['messages']]) diff --git a/openstack_dashboard/dashboards/project/volumes/tabs.py b/openstack_dashboard/dashboards/project/volumes/tabs.py index e067c9f514..b9b375341a 100644 --- a/openstack_dashboard/dashboards/project/volumes/tabs.py +++ b/openstack_dashboard/dashboards/project/volumes/tabs.py @@ -62,6 +62,7 @@ class VolumeTab(tabs.TableTab, VolumeTableMixIn): name = _("Volumes") slug = "volumes_tab" template_name = ("horizon/common/_detail_table.html") + preload = False def get_volumes_data(self): volumes = self._get_volumes() @@ -75,6 +76,7 @@ class SnapshotTab(tabs.TableTab): name = _("Volume Snapshots") slug = "snapshots_tab" template_name = ("horizon/common/_detail_table.html") + preload = False def get_volume_snapshots_data(self): if api.base.is_service_enabled(self.request, 'volume'): @@ -102,6 +104,7 @@ class BackupsTab(tabs.TableTab, VolumeTableMixIn): name = _("Volume Backups") slug = "backups_tab" template_name = ("horizon/common/_detail_table.html") + preload = False def allowed(self, request): return api.cinder.volume_backup_supported(self.request) diff --git a/openstack_dashboard/dashboards/project/volumes/test.py b/openstack_dashboard/dashboards/project/volumes/test.py index 6cf39c0ba4..6d4f041106 100644 --- a/openstack_dashboard/dashboards/project/volumes/test.py +++ b/openstack_dashboard/dashboards/project/volumes/test.py @@ -22,6 +22,8 @@ from openstack_dashboard.test import helpers as test INDEX_URL = reverse('horizon:project:volumes:index') +VOLUME_SNAPSHOTS_TAB_URL = reverse('horizon:project:volumes:snapshots_tab') +VOLUME_BACKUPS_TAB_URL = reverse('horizon:project:volumes:backups_tab') class VolumeAndSnapshotsTests(test.TestCase): @@ -58,7 +60,17 @@ class VolumeAndSnapshotsTests(test.TestCase): self.assertEqual(res.status_code, 200) self.assertTemplateUsed(res, 'project/volumes/index.html') - def test_index_back_supported(self): + # Explicitly load the other tabs. If this doesn't work the test + # will fail due to "Expected methods never called." + res = self.client.get(VOLUME_SNAPSHOTS_TAB_URL) + self.assertEqual(res.status_code, 200) + self.assertTemplateUsed(res, 'project/volumes/index.html') + + if backup_supported: + res = self.client.get(VOLUME_BACKUPS_TAB_URL) + self.assertTemplateUsed(res, 'project/volumes/index.html') + + def test_index_backup_supported(self): self._test_index(backup_supported=True) def test_index_backup_not_supported(self): diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py index b5d35029e9..2a1f9ecd06 100644 --- a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py +++ b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py @@ -706,9 +706,7 @@ class VolumeViewTests(test.TestCase): @test.create_stubs({cinder: ('tenant_absolute_limits', 'volume_list', - 'volume_snapshot_list', 'volume_backup_supported', - 'volume_backup_list', 'volume_delete',), api.nova: ('server_list',)}) def test_delete_volume(self): @@ -724,17 +722,10 @@ class VolumeViewTests(test.TestCase): cinder.volume_delete(IsA(http.HttpRequest), volume.id) api.nova.server_list(IsA(http.HttpRequest), search_opts=None).\ AndReturn([self.servers.list(), False]) - cinder.volume_snapshot_list(IsA(http.HttpRequest)).\ - AndReturn(self.cinder_volume_snapshots.list()) cinder.volume_list(IsA(http.HttpRequest), search_opts=None).\ AndReturn(volumes) - cinder.volume_backup_list(IsA(http.HttpRequest)).\ - AndReturn(self.cinder_volume_backups.list()) - cinder.volume_list(IsA(http.HttpRequest)).\ - AndReturn(volumes) api.nova.server_list(IsA(http.HttpRequest), search_opts=None).\ AndReturn([self.servers.list(), False]) - cinder.volume_list(IsA(http.HttpRequest)).AndReturn(volumes) cinder.tenant_absolute_limits(IsA(http.HttpRequest)).MultipleTimes().\ AndReturn(self.cinder_limits['absolute']) @@ -747,9 +738,7 @@ class VolumeViewTests(test.TestCase): @test.create_stubs({cinder: ('tenant_absolute_limits', 'volume_list', - 'volume_snapshot_list', 'volume_backup_supported', - 'volume_backup_list', 'volume_delete',), api.nova: ('server_list',)}) def test_delete_volume_error_existing_snapshot(self): @@ -772,13 +761,6 @@ class VolumeViewTests(test.TestCase): AndReturn(volumes) api.nova.server_list(IsA(http.HttpRequest), search_opts=None).\ AndReturn([self.servers.list(), False]) - cinder.volume_snapshot_list(IsA(http.HttpRequest))\ - .AndReturn(self.cinder_volume_snapshots.list()) - cinder.volume_list(IsA(http.HttpRequest)).AndReturn(volumes) - cinder.volume_backup_list(IsA(http.HttpRequest)).\ - AndReturn(self.cinder_volume_backups.list()) - cinder.volume_list(IsA(http.HttpRequest)).\ - AndReturn(volumes) cinder.tenant_absolute_limits(IsA(http.HttpRequest)).MultipleTimes().\ AndReturn(self.cinder_limits['absolute']) self.mox.ReplayAll() @@ -872,9 +854,7 @@ class VolumeViewTests(test.TestCase): @test.create_stubs({cinder: ('tenant_absolute_limits', 'volume_list', - 'volume_snapshot_list', - 'volume_backup_supported', - 'volume_backup_list',), + 'volume_backup_supported',), api.nova: ('server_list',)}) def test_create_button_disabled_when_quota_exceeded(self): limits = self.cinder_limits['absolute'] @@ -887,12 +867,6 @@ class VolumeViewTests(test.TestCase): .AndReturn(volumes) api.nova.server_list(IsA(http.HttpRequest), search_opts=None)\ .AndReturn([self.servers.list(), False]) - cinder.volume_snapshot_list(IsA(http.HttpRequest))\ - .AndReturn(self.cinder_volume_snapshots.list()) - cinder.volume_list(IsA(http.HttpRequest)).AndReturn(volumes) - cinder.volume_backup_list(IsA(http.HttpRequest))\ - .AndReturn(self.cinder_volume_backups.list()) - cinder.volume_list(IsA(http.HttpRequest)).AndReturn(volumes) cinder.tenant_absolute_limits(IsA(http.HttpRequest))\ .MultipleTimes().AndReturn(limits) self.mox.ReplayAll() @@ -1062,7 +1036,7 @@ class VolumeViewTests(test.TestCase): def test_encryption_true(self): self._test_encryption(True) - @test.create_stubs({cinder: ('volume_list', 'volume_snapshot_list', + @test.create_stubs({cinder: ('volume_list', 'volume_backup_supported', 'tenant_absolute_limits'), api.nova: ('server_list',)}) @@ -1073,15 +1047,13 @@ class VolumeViewTests(test.TestCase): limits = self.cinder_limits['absolute'] cinder.volume_backup_supported(IsA(http.HttpRequest))\ - .MultipleTimes().AndReturn(False) + .MultipleTimes('backup_supported').AndReturn(False) cinder.volume_list(IsA(http.HttpRequest), search_opts=None)\ - .MultipleTimes().AndReturn(self.volumes.list()) - cinder.volume_list(IsA(http.HttpRequest)).AndReturn([]) - cinder.volume_snapshot_list(IsA(http.HttpRequest)).AndReturn([]) + .AndReturn(self.volumes.list()) api.nova.server_list(IsA(http.HttpRequest), search_opts=None)\ - .AndReturn([self.servers.list(), False]) + .AndReturn([self.servers.list(), False]) cinder.tenant_absolute_limits(IsA(http.HttpRequest))\ - .MultipleTimes().AndReturn(limits) + .MultipleTimes('limits').AndReturn(limits) self.mox.ReplayAll()