From 1a1ca889d806412adba14aef7b0be7aa5ea23167 Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Sat, 4 Oct 2014 12:09:11 +0800 Subject: [PATCH] * Removed all Django 1.7 fix-up, as they were applied upstream. Only disable-failed-django-1.7-test.patch remains, as nobody was able to work on it and solve it. Rewritten-From: 4f1333339333a2bb0fe8bdd95c84c250008d66b0 --- xenial/debian/changelog | 3 + ...ror_from_table_column_summation_code.patch | 105 ------------------ ...curityGroup-object-is-not-iterable-t.patch | 33 ------ xenial/debian/patches/series | 2 - 4 files changed, 3 insertions(+), 140 deletions(-) delete mode 100644 xenial/debian/patches/0008_Handle_TypeError_from_table_column_summation_code.patch delete mode 100644 xenial/debian/patches/0009_Fix-TypeError-SecurityGroup-object-is-not-iterable-t.patch diff --git a/xenial/debian/changelog b/xenial/debian/changelog index 910ab01..6902d15 100644 --- a/xenial/debian/changelog +++ b/xenial/debian/changelog @@ -3,6 +3,9 @@ horizon (2014.2~rc1-1) experimental; urgency=medium * New upstream release. * Added missing python-xstatic-bootstrap-datepicker depends. * Updated (build-)depends for this release. + * Removed all Django 1.7 fix-up, as they were applied upstream. Only + disable-failed-django-1.7-test.patch remains, as nobody was able to work + on it and solve it. -- Thomas Goirand Sat, 04 Oct 2014 11:46:51 +0800 diff --git a/xenial/debian/patches/0008_Handle_TypeError_from_table_column_summation_code.patch b/xenial/debian/patches/0008_Handle_TypeError_from_table_column_summation_code.patch deleted file mode 100644 index ab2cd60..0000000 --- a/xenial/debian/patches/0008_Handle_TypeError_from_table_column_summation_code.patch +++ /dev/null @@ -1,105 +0,0 @@ -Description: Fix summation code to handle invalid input data - This commit fixes multiple test failures with Django 1.7 that all ended with - this: - . - File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 734, in resolve - value = self._resolve_lookup(context) - File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 788, in _resolve_lookup - current = current() - File "/home/rhertzog/tmp/django17/horizon/horizon/tables/base.py", line 404, in get_summation - summation = summation_function(data) - File "/home/rhertzog/tmp/django17/horizon/horizon/tables/base.py", line 206, in - "average": lambda data: sum(data, 0.0) / len(data) - TypeError: unsupported operand type(s) for +: 'float' and 'str' - . - With Django 1.6, the template code that looked up the variable behind - get_summation was catching the TypeError exception: - . - try: # method call (assuming no args required) - current = current() - except TypeError: # arguments *were* required - # GOTCHA: This will also catch any TypeError - # raised in the function itself. - current = settings.TEMPLATE_STRING_IF_INVALID # invalid method call - . - With Django 1.7, the code has been refined to catch the exception only when - the function really requires argument (which get_summation() doesn't): - . - try: # method call (assuming no args required) - current = current() - except TypeError: - try: - getcallargs(current) - except TypeError: # arguments *were* required - current = settings.TEMPLATE_STRING_IF_INVALID # invalid method call - else: - raise - . - So instead of blindly relying on sum(), I introduced a safe_sum() and safe_average() - functions which mimick the behaviour we got with Django 1.6 by returning an empty - string when we have invalid input data. -Author: Raphael Hertzog -Date: Mon, 4 Aug 2014 22:27:51 +0200 - -From d9c8a2e62fbf620eef4d1bdb292cb6ca6b830f17 Mon Sep 17 00:00:00 2001 -From: Akihiro Motoki -Date: Wed, 13 Aug 2014 04:05:11 +0900 -Subject: [PATCH] Handle TypeError from table column summation code - -This commit catches TypeError from horizon.tables.Column -summation calculation. This TypeError is caught inside Django -until Django 1.6, but Django 1.7 code is refined to catch -more specific case and it leads to horizon unit test failure. - -Closes-Bug: #1355939 -Change-Id: I9d5b4565f1238a9880ccf117f2ea623fed466a44 ---- - horizon/tables/base.py | 14 ++++++++------ - horizon/test/tests/tables.py | 9 +++++++++ - 2 files changed, 17 insertions(+), 6 deletions(-) - -Index: horizon/horizon/tables/base.py -=================================================================== ---- horizon.orig/horizon/tables/base.py -+++ horizon/horizon/tables/base.py -@@ -413,12 +413,14 @@ class Column(html.HTMLElement): - data = filter(lambda datum: datum is not None, data) - - if len(data): -- summation = summation_function(data) -- for filter_func in self.filters: -- summation = filter_func(summation) -- return summation -- else: -- return None -+ try: -+ summation = summation_function(data) -+ for filter_func in self.filters: -+ summation = filter_func(summation) -+ return summation -+ except TypeError: -+ pass -+ return None - - - class Row(html.HTMLElement): -Index: horizon/horizon/test/tests/tables.py -=================================================================== ---- horizon.orig/horizon/test/tests/tables.py -+++ horizon/horizon/test/tests/tables.py -@@ -1110,6 +1110,15 @@ class DataTableTests(test.TestCase): - self.assertNotContains(res, '3.0') - self.assertNotContains(res, '6') - -+ # Even if "average" summation method is specified, -+ # we have summation fields but no value is provoded -+ # if the provided data cannot be summed. -+ table = MyTable(self.request, TEST_DATA) -+ res = http.HttpResponse(table.render()) -+ self.assertContains(res, '3.0') -+ self.assertNotContains(res, '6') -+ - def test_table_action_attributes(self): - table = MyTable(self.request, TEST_DATA) - self.assertTrue(table.has_actions) diff --git a/xenial/debian/patches/0009_Fix-TypeError-SecurityGroup-object-is-not-iterable-t.patch b/xenial/debian/patches/0009_Fix-TypeError-SecurityGroup-object-is-not-iterable-t.patch deleted file mode 100644 index 6aed8d5..0000000 --- a/xenial/debian/patches/0009_Fix-TypeError-SecurityGroup-object-is-not-iterable-t.patch +++ /dev/null @@ -1,33 +0,0 @@ -Description: TypeError: 'SecurityGroup' object is not iterable test failure with Django 1.7 - The two tests modified here were incorrectly defining instance.security_groups - as a single value instead of a list. - . - Apparently Django 1.7 is no longer happy trying to iterate something that is - not an iterable. - . - The other test_instance_details_*() were already doing the correct thing so - just copy over the logic. -From: Raphael Hertzog -Forwarded: https://review.openstack.org/111934 -Date: Mon, 4 Aug 2014 22:48:43 +0200 - ---- horizon-2014.2~b3.orig/openstack_dashboard/dashboards/project/instances/tests.py -+++ horizon-2014.2~b3/openstack_dashboard/dashboards/project/instances/tests.py -@@ -686,7 +686,7 @@ class InstanceTests(helpers.TestCase): - def test_instance_details_volumes(self): - server = self.servers.first() - volumes = [self.volumes.list()[1]] -- security_group = self.security_groups.first() -+ security_group = self.security_groups.list() - - res = self._get_instance_details(server, volumes_return=volumes, - security_groups_return=security_group) -@@ -698,7 +698,7 @@ class InstanceTests(helpers.TestCase): - def test_instance_details_volume_sorting(self): - server = self.servers.first() - volumes = self.volumes.list()[1:3] -- security_group = self.security_groups.first() -+ security_group = self.security_groups.list() - - res = self._get_instance_details(server, volumes_return=volumes, - security_groups_return=security_group) diff --git a/xenial/debian/patches/series b/xenial/debian/patches/series index e56d6bd..15031e2 100644 --- a/xenial/debian/patches/series +++ b/xenial/debian/patches/series @@ -1,6 +1,4 @@ fix-dashboard-django-wsgi.patch fix-dashboard-manage.patch fixed-horizon-MANIFEST.in.patch -0008_Handle_TypeError_from_table_column_summation_code.patch -0009_Fix-TypeError-SecurityGroup-object-is-not-iterable-t.patch disable-failed-django-1.7-test.patch -- 2.45.2