From 06c81a4a071270f4ba9ffabf218f0b187e141e22 Mon Sep 17 00:00:00 2001 From: Tatiana Ovchinnikova Date: Tue, 9 Aug 2016 16:04:15 +0300 Subject: [PATCH] Fix get_disabled_quotas Disabled quotas should be treated as a set, not as a list, or else instead of action buttons we'll get a traceback: File "/manila-ui/manila_ui/dashboards/project/shares/__init__.py", line 129, in get_disabled_quotas disabled_quotas.extend(_get_manila_disabled_quotas(request)) AttributeError: 'set' object has no attribute 'extend' Change-Id: I5364a8b7fbea3f166264c33ffb6eff341e140bdf Closes-Bug: #1611368 --- manila_ui/dashboards/project/shares/__init__.py | 2 +- .../dashboards/project/shares/shares/tests.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/manila_ui/dashboards/project/shares/__init__.py b/manila_ui/dashboards/project/shares/__init__.py index 31085243..c2749ec4 100644 --- a/manila_ui/dashboards/project/shares/__init__.py +++ b/manila_ui/dashboards/project/shares/__init__.py @@ -126,7 +126,7 @@ def get_tenant_quota_data(f, request, disabled_quotas=None, tenant_id=None): @wrap(quotas.get_disabled_quotas) def get_disabled_quotas(f, request): disabled_quotas = f(request) - disabled_quotas.extend(_get_manila_disabled_quotas(request)) + disabled_quotas.update(_get_manila_disabled_quotas(request)) return disabled_quotas diff --git a/manila_ui/tests/dashboards/project/shares/shares/tests.py b/manila_ui/tests/dashboards/project/shares/shares/tests.py index 42a2d3bd..73f1a02b 100644 --- a/manila_ui/tests/dashboards/project/shares/shares/tests.py +++ b/manila_ui/tests/dashboards/project/shares/shares/tests.py @@ -21,6 +21,7 @@ from manila_ui.api import manila as api_manila from manila_ui.tests.dashboards.project.shares import test_data from manila_ui.tests import helpers as test +from openstack_dashboard.api import base from openstack_dashboard.api import neutron from openstack_dashboard.api import nova from openstack_dashboard.usage import quotas @@ -28,6 +29,19 @@ from openstack_dashboard.usage import quotas SHARE_INDEX_URL = reverse('horizon:project:shares:index') +class QuotaTests(test.TestCase): + + def test_get_disabled_quotas(self): + self.mock_object( + base, "is_service_enabled", mock.Mock(return_value=False)) + + result_quotas = quotas.get_disabled_quotas(self.request) + expected_quotas = set( + quotas.QUOTA_FIELDS + quotas.MISSING_QUOTA_FIELDS) + + self.assertItemsEqual(result_quotas, expected_quotas) + + @ddt.ddt class ShareViewTests(test.TestCase):