[python-django-horizon] Removed selenium, mocked cinder and trove calls
Matthias Runge
mrunge at fedoraproject.org
Thu Dec 12 07:37:25 UTC 2013
commit 3b9ec6a6f7c9a024b687238c0c6d2d215a68271a
Author: Matthias Runge <mrunge at redhat.com>
Date: Thu Dec 12 08:22:12 2013 +0100
Removed selenium, mocked cinder and trove calls
...SV-Summary-not-working-inside-Admin-panel.patch | 173 ++++++++++++++++++++
...T_KEYSTORE-to-var-lib-openstack-dashboard.patch | 45 -----
...s-Trove-mock-to-tests-in-database_backups.patch | 56 +++++++
0011-Run-selenium-tests-only-when-requested.patch | 55 ++++++
...arning-and-a-hacking-error-in-settings.py.patch | 49 ++++++
python-django-horizon.spec | 8 +-
6 files changed, 340 insertions(+), 46 deletions(-)
---
diff --git a/0009-CSV-Summary-not-working-inside-Admin-panel.patch b/0009-CSV-Summary-not-working-inside-Admin-panel.patch
new file mode 100644
index 0000000..8698cec
--- /dev/null
+++ b/0009-CSV-Summary-not-working-inside-Admin-panel.patch
@@ -0,0 +1,173 @@
+From 9dbe5e25607416a4423e8d05fb3d192f2f6e5720 Mon Sep 17 00:00:00 2001
+From: "Leandro I. Costantino" <leandro.i.costantino at intel.com>
+Date: Fri, 6 Dec 2013 10:52:24 -0500
+Subject: [PATCH] CSV Summary not working inside Admin panel.
+
+When browsing Project usages from 'Admin->Projects->More->View Usages'
+an AttributeError exception is thrown due to missing csv_render_class
+attribute.
+Also, project_id instead of tenant_id in BaseUsage were expected, so
+any request to /admin/projects/[id]/usage/ will always return the current
+tenant from session.
+This fix reuse logic from project/overview/ into this view.
+
+Change-Id: I7d762569a7de176fdb8545a226e563afac34adae
+Closes-Bug: #1255667
+(cherry picked from commit 340bf16be00706235b66309f327611c1bca02f50)
+---
+ .../dashboards/admin/projects/tests.py | 63 ++++++++++++++++++++++
+ .../dashboards/admin/projects/urls.py | 2 +-
+ .../dashboards/admin/projects/views.py | 5 +-
+ openstack_dashboard/usage/views.py | 4 +-
+ 4 files changed, 71 insertions(+), 3 deletions(-)
+
+diff --git a/openstack_dashboard/dashboards/admin/projects/tests.py b/openstack_dashboard/dashboards/admin/projects/tests.py
+index 976d221..961af23 100644
+--- a/openstack_dashboard/dashboards/admin/projects/tests.py
++++ b/openstack_dashboard/dashboards/admin/projects/tests.py
+@@ -15,11 +15,13 @@
+ # under the License.
+
+ import copy
++import datetime
+ import logging
+
+ from django.core.urlresolvers import reverse # noqa
+ from django import http
+ from django.test.utils import override_settings # noqa
++from django.utils import timezone
+
+ from mox import IgnoreArg # noqa
+ from mox import IsA # noqa
+@@ -30,6 +32,7 @@ from horizon.workflows import views
+ from openstack_dashboard import api
+ from openstack_dashboard.dashboards.admin.projects import workflows
+ from openstack_dashboard.test import helpers as test
++from openstack_dashboard import usage
+ from openstack_dashboard.usage import quotas
+
+ from selenium.webdriver import ActionChains # noqa
+@@ -1446,6 +1449,66 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
+ logging.disable(logging.NOTSET)
+
+
++class UsageViewTests(test.BaseAdminViewTests):
++ def _stub_nova_api_calls(self, nova_stu_enabled=True):
++ self.mox.StubOutWithMock(api.nova, 'usage_get')
++ self.mox.StubOutWithMock(api.nova, 'tenant_absolute_limits')
++ self.mox.StubOutWithMock(api.nova, 'extension_supported')
++ api.nova.extension_supported(
++ 'SimpleTenantUsage', IsA(http.HttpRequest)) \
++ .AndReturn(nova_stu_enabled)
++
++ def _stub_neutron_api_calls(self, neutron_sg_enabled=True):
++ self.mox.StubOutWithMock(api.neutron, 'is_extension_supported')
++ self.mox.StubOutWithMock(api.network, 'tenant_floating_ip_list')
++ if neutron_sg_enabled:
++ self.mox.StubOutWithMock(api.network, 'security_group_list')
++ api.neutron.is_extension_supported(
++ IsA(http.HttpRequest),
++ 'security-group').AndReturn(neutron_sg_enabled)
++ api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
++ .AndReturn(self.floating_ips.list())
++ if neutron_sg_enabled:
++ api.network.security_group_list(IsA(http.HttpRequest)) \
++ .AndReturn(self.q_secgroups.list())
++
++ def test_usage_csv(self):
++ self._test_usage_csv(nova_stu_enabled=True)
++
++ def test_usage_csv_disabled(self):
++ self._test_usage_csv(nova_stu_enabled=False)
++
++ def _test_usage_csv(self, nova_stu_enabled=True):
++ now = timezone.now()
++ usage_obj = api.nova.NovaUsage(self.usages.first())
++ self._stub_nova_api_calls(nova_stu_enabled)
++ api.nova.extension_supported(
++ 'SimpleTenantUsage', IsA(http.HttpRequest)) \
++ .AndReturn(nova_stu_enabled)
++ start = datetime.datetime(now.year, now.month, now.day, 0, 0, 0, 0)
++ end = datetime.datetime(now.year, now.month, now.day, 23, 59, 59, 0)
++
++ if nova_stu_enabled:
++ api.nova.usage_get(IsA(http.HttpRequest),
++ self.tenant.id,
++ start, end).AndReturn(usage_obj)
++ api.nova.tenant_absolute_limits(IsA(http.HttpRequest))\
++ .AndReturn(self.limits['absolute'])
++ self._stub_neutron_api_calls()
++ self.mox.ReplayAll()
++
++ project_id = self.tenants.first().id
++ csv_url = reverse('horizon:admin:projects:usage',
++ args=[project_id]) + "?format=csv"
++ res = self.client.get(csv_url)
++ self.assertTemplateUsed(res, 'project/overview/usage.csv')
++
++ self.assertTrue(isinstance(res.context['usage'], usage.ProjectUsage))
++ hdr = ('Instance Name,VCPUs,Ram (MB),Disk (GB),Usage (Hours),'
++ 'Uptime(Seconds),State')
++ self.assertContains(res, '%s\r\n' % hdr)
++
++
+ class SeleniumTests(test.SeleniumAdminTestCase):
+ @test.create_stubs(
+ {api.keystone: ('tenant_list', 'tenant_get', 'tenant_update')})
+diff --git a/openstack_dashboard/dashboards/admin/projects/urls.py b/openstack_dashboard/dashboards/admin/projects/urls.py
+index ea89f24..c283a44 100644
+--- a/openstack_dashboard/dashboards/admin/projects/urls.py
++++ b/openstack_dashboard/dashboards/admin/projects/urls.py
+@@ -29,6 +29,6 @@ urlpatterns = patterns('',
+ url(r'^create$', views.CreateProjectView.as_view(), name='create'),
+ url(r'^(?P<tenant_id>[^/]+)/update/$',
+ views.UpdateProjectView.as_view(), name='update'),
+- url(r'^(?P<tenant_id>[^/]+)/usage/$',
++ url(r'^(?P<project_id>[^/]+)/usage/$',
+ views.ProjectUsageView.as_view(), name='usage'),
+ )
+diff --git a/openstack_dashboard/dashboards/admin/projects/views.py b/openstack_dashboard/dashboards/admin/projects/views.py
+index f9af869..5a45d42 100644
+--- a/openstack_dashboard/dashboards/admin/projects/views.py
++++ b/openstack_dashboard/dashboards/admin/projects/views.py
+@@ -34,7 +34,8 @@ from openstack_dashboard.dashboards.admin.projects \
+ import tables as project_tables
+ from openstack_dashboard.dashboards.admin.projects \
+ import workflows as project_workflows
+-
++from openstack_dashboard.dashboards.project.overview \
++ import views as project_views
+
+ PROJECT_INFO_FIELDS = ("domain_id",
+ "domain_name",
+@@ -94,6 +95,8 @@ class ProjectUsageView(usage.UsageView):
+ table_class = usage.ProjectUsageTable
+ usage_class = usage.ProjectUsage
+ template_name = 'admin/projects/usage.html'
++ csv_response_class = project_views.ProjectUsageCsvRenderer
++ csv_template_name = 'project/overview/usage.csv'
+
+ def get_data(self):
+ super(ProjectUsageView, self).get_data()
+diff --git a/openstack_dashboard/usage/views.py b/openstack_dashboard/usage/views.py
+index 40e566f..6d04753 100644
+--- a/openstack_dashboard/usage/views.py
++++ b/openstack_dashboard/usage/views.py
+@@ -18,6 +18,7 @@ from openstack_dashboard.usage import base
+ class UsageView(tables.DataTableView):
+ usage_class = None
+ show_terminated = True
++ csv_template_name = None
+
+ def __init__(self, *args, **kwargs):
+ super(UsageView, self).__init__(*args, **kwargs)
+@@ -27,7 +28,8 @@ class UsageView(tables.DataTableView):
+
+ def get_template_names(self):
+ if self.request.GET.get('format', 'html') == 'csv':
+- return ".".join((self.template_name.rsplit('.', 1)[0], 'csv'))
++ return (self.csv_template_name or
++ ".".join((self.template_name.rsplit('.', 1)[0], 'csv')))
+ return self.template_name
+
+ def get_content_type(self):
diff --git a/0010-Adds-Trove-mock-to-tests-in-database_backups.patch b/0010-Adds-Trove-mock-to-tests-in-database_backups.patch
new file mode 100644
index 0000000..9aa8462
--- /dev/null
+++ b/0010-Adds-Trove-mock-to-tests-in-database_backups.patch
@@ -0,0 +1,56 @@
+From 38f856cf18e6a009cf286efcece6d4b2afbdb2e3 Mon Sep 17 00:00:00 2001
+From: Cristian A Sanchez <cristian.a.sanchez at intel.com>
+Date: Mon, 9 Dec 2013 12:23:28 -0800
+Subject: [PATCH] Adds Trove mock to tests in database_backups
+
+Test cases in database_backups/tests.py now have a mock for the
+method api.trove.instance_get(). The absence of this mock was
+causing real HTTP requests to Trove.
+
+Change-Id: Icf760d7eaba2d136626dbbbbf6e49260a18fb874
+Closes-Bug: #1255936
+(cherry picked from commit 6afa1fdf1b660cf5932a0848f84a5262f26e3bb3)
+---
+ .../dashboards/project/database_backups/tests.py | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/openstack_dashboard/dashboards/project/database_backups/tests.py b/openstack_dashboard/dashboards/project/database_backups/tests.py
+index ccff48d..68996d5 100644
+--- a/openstack_dashboard/dashboards/project/database_backups/tests.py
++++ b/openstack_dashboard/dashboards/project/database_backups/tests.py
+@@ -27,11 +27,16 @@ DETAILS_URL = reverse('horizon:project:database_backups:detail', args=['id'])
+
+
+ class DatabasesBackupsTests(test.TestCase):
+- @test.create_stubs({api.trove: ('backup_list', )})
++ @test.create_stubs({api.trove: ('backup_list', 'instance_get')})
+ def test_index(self):
+ api.trove.backup_list(IsA(http.HttpRequest))\
+ .AndReturn(self.database_backups.list())
+
++ api.trove.instance_get(IsA(http.HttpRequest),
++ IsA(str))\
++ .MultipleTimes()\
++ .AndReturn(self.databases.first())
++
+ self.mox.ReplayAll()
+
+ res = self.client.get(INDEX_URL)
+@@ -75,12 +80,16 @@ class DatabasesBackupsTests(test.TestCase):
+ self.assertTemplateUsed(res,
+ 'project/database_backups/backup.html')
+
+- @test.create_stubs({api.trove: ('backup_get',)})
++ @test.create_stubs({api.trove: ('backup_get', 'instance_get')})
+ def test_detail_backup(self):
+ api.trove.backup_get(IsA(http.HttpRequest),
+ IsA(unicode))\
+ .AndReturn(self.database_backups.first())
+
++ api.trove.instance_get(IsA(http.HttpRequest),
++ IsA(str))\
++ .AndReturn(self.databases.first())
++
+ self.mox.ReplayAll()
+ res = self.client.get(DETAILS_URL)
+
diff --git a/0011-Run-selenium-tests-only-when-requested.patch b/0011-Run-selenium-tests-only-when-requested.patch
new file mode 100644
index 0000000..f60cf80
--- /dev/null
+++ b/0011-Run-selenium-tests-only-when-requested.patch
@@ -0,0 +1,55 @@
+From 055d909aee76d36814723d81cfa98377657c2251 Mon Sep 17 00:00:00 2001
+From: Matthias Runge <mrunge at redhat.com>
+Date: Tue, 10 Dec 2013 10:37:55 +0100
+Subject: [PATCH] Run selenium tests only when requested
+
+In some environments, it's not wanted or possible
+to execute selenium tests. These are only executed, if
+--with-selenium is specified.
+
+Change-Id: I39c40ac1feb64565f0bcbc97f6345d203b1d816e
+Closes-Bug: 1259072
+(cherry picked from commit f95b2b68d2219f717ae0e604af7e61e1a24dde6e)
+---
+ openstack_dashboard/dashboards/admin/projects/tests.py | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/openstack_dashboard/dashboards/admin/projects/tests.py b/openstack_dashboard/dashboards/admin/projects/tests.py
+index 961af23..ba4803e 100644
+--- a/openstack_dashboard/dashboards/admin/projects/tests.py
++++ b/openstack_dashboard/dashboards/admin/projects/tests.py
+@@ -17,11 +17,13 @@
+ import copy
+ import datetime
+ import logging
++import os
+
+ from django.core.urlresolvers import reverse # noqa
+ from django import http
+ from django.test.utils import override_settings # noqa
+ from django.utils import timezone
++from django.utils import unittest
+
+ from mox import IgnoreArg # noqa
+ from mox import IsA # noqa
+@@ -35,7 +37,10 @@ from openstack_dashboard.test import helpers as test
+ from openstack_dashboard import usage
+ from openstack_dashboard.usage import quotas
+
+-from selenium.webdriver import ActionChains # noqa
++with_sel = os.environ.get('WITH_SELENIUM', False)
++if with_sel:
++ from selenium.webdriver import ActionChains # noqa
++
+ from socket import timeout as socket_timeout # noqa
+
+
+@@ -1509,6 +1514,8 @@ class UsageViewTests(test.BaseAdminViewTests):
+ self.assertContains(res, '%s\r\n' % hdr)
+
+
++ at unittest.skipUnless(os.environ.get('WITH_SELENIUM', False),
++ "The WITH_SELENIUM env variable is not set.")
+ class SeleniumTests(test.SeleniumAdminTestCase):
+ @test.create_stubs(
+ {api.keystone: ('tenant_list', 'tenant_get', 'tenant_update')})
diff --git a/0012-fix-a-warning-and-a-hacking-error-in-settings.py.patch b/0012-fix-a-warning-and-a-hacking-error-in-settings.py.patch
new file mode 100644
index 0000000..5e06172
--- /dev/null
+++ b/0012-fix-a-warning-and-a-hacking-error-in-settings.py.patch
@@ -0,0 +1,49 @@
+From de4dba8d54b477f4d940c63d87ae2db62730396e Mon Sep 17 00:00:00 2001
+From: Matthias Runge <mrunge at redhat.com>
+Date: Wed, 11 Dec 2013 12:26:02 +0100
+Subject: [PATCH] fix a warning and a hacking error in settings.py
+
+---
+ openstack_dashboard/settings.py | 4 ++--
+ tox.ini | 4 +++-
+ 2 files changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py
+index 20edb90..08bffb5 100644
+--- a/openstack_dashboard/settings.py
++++ b/openstack_dashboard/settings.py
+@@ -125,7 +125,7 @@ TEMPLATE_LOADERS = (
+
+ TEMPLATE_DIRS = (
+ os.path.join(ROOT_PATH, 'templates'),
+-)
++)
+
+ STATICFILES_FINDERS = (
+ 'compressor.finders.CompressorFinder',
+@@ -168,7 +168,7 @@ THEME_APP = 'openstack_dashboard_theme'
+ try:
+ __import__(THEME_APP)
+ INSTALLED_APPS = (THEME_APP,) + INSTALLED_APPS
+-except:
++except Exception:
+ pass
+
+
+diff --git a/tox.ini b/tox.ini
+index 23ad8d6..9f450f2 100644
+--- a/tox.ini
++++ b/tox.ini
+@@ -32,9 +32,11 @@ downloadcache = ~/cache/pip
+ [flake8]
+ builtins = _
+ exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py
++# E122 continuation line missing indentation or outdented
++# E126 continuation line over-indented for hanging indent
+ # E127 continuation line over-indented for visual indent
+ # E128 continuation line under-indented for visual indent
+ # H701 empty localization string
+ # H702 Formatting operation should be outside of localization method call
+ # H803 git commit title should not end with period (disabled on purpose, see bug #1236621)
+-ignore = E127,E128,H701,H702,H803
++ignore = E122,E126,E127,E128,H701,H702,H803
diff --git a/python-django-horizon.spec b/python-django-horizon.spec
index d6a494d..fbb43c6 100644
--- a/python-django-horizon.spec
+++ b/python-django-horizon.spec
@@ -30,7 +30,10 @@ Patch0005: 0005-move-RBAC-policy-files-and-checks-to-etc-openstack-d.patch
Patch0006: 0006-move-SECRET_KEY-secret_key_store-to-tmp.patch
Patch0007: 0007-fix-up-issues-with-customization.patch
Patch0008: 0008-do-not-truncate-the-logo-related-rhbz-877138.patch
-Patch0009: 0009-move-SECRET_KEYSTORE-to-var-lib-openstack-dashboard.patch
+Patch0009: 0009-CSV-Summary-not-working-inside-Admin-panel.patch
+Patch0010: 0010-Adds-Trove-mock-to-tests-in-database_backups.patch
+Patch0011: 0011-Run-selenium-tests-only-when-requested.patch
+Patch0012: 0012-fix-a-warning-and-a-hacking-error-in-settings.py.patch
@@ -164,6 +167,9 @@ Customization module for OpenStack Dashboard to provide a branded logo.
%patch0007 -p1
%patch0008 -p1
%patch0009 -p1
+%patch0010 -p1
+%patch0011 -p1
+%patch0012 -p1
# remove unnecessary .po files
find . -name "django*.po" -exec rm -f '{}' \;
More information about the scm-commits
mailing list