Package: python-django-treebeard / 4.3.1+dfsg-1

0004-Fix-tests-with-Django-2.1.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
From: Michael Fladischer <fladi@debian.org>
Date: Fri, 21 Feb 2020 21:28:09 +0100
Subject: Fix tests with Django 2.1.

---
 treebeard/tests/test_treebeard.py | 123 ++++++++++++++++++++++++++++----------
 1 file changed, 90 insertions(+), 33 deletions(-)

diff --git a/treebeard/tests/test_treebeard.py b/treebeard/tests/test_treebeard.py
index 9f992a8..3a28ff1 100644
--- a/treebeard/tests/test_treebeard.py
+++ b/treebeard/tests/test_treebeard.py
@@ -5,9 +5,10 @@ from __future__ import unicode_literals
 import datetime
 import os
 
+from django import VERSION as DJANGO_VERSION
 from django.contrib.admin.sites import AdminSite
 from django.contrib.admin.views.main import ChangeList
-from django.contrib.auth.models import User
+from django.contrib.auth.models import User, AnonymousUser
 from django.contrib.messages.storage.fallback import FallbackStorage
 from django.db.models import Q
 from django.template import Template, Context
@@ -2366,16 +2367,23 @@ class TestAdminTree(TestNonEmptyTree):
         """
         model = model_without_proxy
         request = RequestFactory().get('/admin/tree/')
+        request.user = AnonymousUser()
         site = AdminSite()
         form_class = movenodeform_factory(model)
         admin_class = admin_factory(form_class)
         m = admin_class(model, site)
         list_display = m.get_list_display(request)
         list_display_links = m.get_list_display_links(request, list_display)
-        cl = ChangeList(request, model, list_display, list_display_links,
-                        m.list_filter, m.date_hierarchy, m.search_fields,
-                        m.list_select_related, m.list_per_page,
-                        m.list_max_show_all, m.list_editable, m)
+        if DJANGO_VERSION < (2, 1):
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m)
+        else:
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m, None)
         cl.formset = None
         context = Context({'cl': cl,
                            'request': request})
@@ -2401,6 +2409,7 @@ class TestAdminTree(TestNonEmptyTree):
         # Add a unicode description
         model.add_root(desc='áéîøü')
         request = RequestFactory().get('/admin/tree/')
+        request.user = AnonymousUser()
         site = AdminSite()
         form_class = movenodeform_factory(model)
         ModelAdmin = admin_factory(form_class)
@@ -2411,10 +2420,16 @@ class TestAdminTree(TestNonEmptyTree):
         m = UnicodeModelAdmin(model, site)
         list_display = m.get_list_display(request)
         list_display_links = m.get_list_display_links(request, list_display)
-        cl = ChangeList(request, model, list_display, list_display_links,
-                        m.list_filter, m.date_hierarchy, m.search_fields,
-                        m.list_select_related, m.list_per_page,
-                        m.list_max_show_all, m.list_editable, m)
+        if DJANGO_VERSION < (2, 1):
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m)
+        else:
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m, None)
         cl.formset = None
         context = Context({'cl': cl,
                            'request': request})
@@ -2437,16 +2452,23 @@ class TestAdminTree(TestNonEmptyTree):
         model = model_without_proxy
         # Filtered GET
         request = RequestFactory().get('/admin/tree/?desc=1')
+        request.user = AnonymousUser()
         site = AdminSite()
         form_class = movenodeform_factory(model)
         admin_class = admin_factory(form_class)
         m = admin_class(model, site)
         list_display = m.get_list_display(request)
         list_display_links = m.get_list_display_links(request, list_display)
-        cl = ChangeList(request, model, list_display, list_display_links,
-                        m.list_filter, m.date_hierarchy, m.search_fields,
-                        m.list_select_related, m.list_per_page,
-                        m.list_max_show_all, m.list_editable, m)
+        if DJANGO_VERSION < (2, 1):
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m)
+        else:
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m, None)
         cl.formset = None
         context = Context({'cl': cl,
                            'request': request})
@@ -2457,12 +2479,19 @@ class TestAdminTree(TestNonEmptyTree):
 
         # Not Filtered GET, it should ignore pagination
         request = RequestFactory().get('/admin/tree/?p=1')
+        request.user = AnonymousUser()
         list_display = m.get_list_display(request)
         list_display_links = m.get_list_display_links(request, list_display)
-        cl = ChangeList(request, model, list_display, list_display_links,
-                        m.list_filter, m.date_hierarchy, m.search_fields,
-                        m.list_select_related, m.list_per_page,
-                        m.list_max_show_all, m.list_editable, m)
+        if DJANGO_VERSION < (2, 1):
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m)
+        else:
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m, None)
         cl.formset = None
         context = Context({'cl': cl,
                            'request': request})
@@ -2473,12 +2502,19 @@ class TestAdminTree(TestNonEmptyTree):
 
         # Not Filtered GET, it should ignore all
         request = RequestFactory().get('/admin/tree/?all=1')
+        request.user = AnonymousUser()
         list_display = m.get_list_display(request)
         list_display_links = m.get_list_display_links(request, list_display)
-        cl = ChangeList(request, model, list_display, list_display_links,
-                        m.list_filter, m.date_hierarchy, m.search_fields,
-                        m.list_select_related, m.list_per_page,
-                        m.list_max_show_all, m.list_editable, m)
+        if DJANGO_VERSION < (2, 1):
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m)
+        else:
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m, None)
         cl.formset = None
         context = Context({'cl': cl,
                            'request': request})
@@ -2499,16 +2535,23 @@ class TestAdminTreeList(TestNonEmptyTree):
         """
         model = model_without_proxy
         request = RequestFactory().get('/admin/tree/')
+        request.user = AnonymousUser()
         site = AdminSite()
         form_class = movenodeform_factory(model)
         admin_class = admin_factory(form_class)
         m = admin_class(model, site)
         list_display = m.get_list_display(request)
         list_display_links = m.get_list_display_links(request, list_display)
-        cl = ChangeList(request, model, list_display, list_display_links,
-                        m.list_filter, m.date_hierarchy, m.search_fields,
-                        m.list_select_related, m.list_per_page,
-                        m.list_max_show_all, m.list_editable, m)
+        if DJANGO_VERSION < (2, 1):
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m)
+        else:
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m, None)
         cl.formset = None
         context = Context({'cl': cl,
                            'request': request})
@@ -2522,16 +2565,23 @@ class TestAdminTreeList(TestNonEmptyTree):
     def test_result_tree_list_with_action(self, model_without_proxy):
         model = model_without_proxy
         request = RequestFactory().get('/admin/tree/')
+        request.user = AnonymousUser()
         site = AdminSite()
         form_class = movenodeform_factory(model)
         admin_class = admin_factory(form_class)
         m = admin_class(model, site)
         list_display = m.get_list_display(request)
         list_display_links = m.get_list_display_links(request, list_display)
-        cl = ChangeList(request, model, list_display, list_display_links,
-                        m.list_filter, m.date_hierarchy, m.search_fields,
-                        m.list_select_related, m.list_per_page,
-                        m.list_max_show_all, m.list_editable, m)
+        if DJANGO_VERSION < (2, 1):
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m)
+        else:
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m, None)
         cl.formset = None
         context = Context({'cl': cl,
                            'request': request,
@@ -2551,6 +2601,7 @@ class TestAdminTreeList(TestNonEmptyTree):
         # Test t GET parameter with value id
         request = RequestFactory().get(
             '/admin/tree/?{0}=id'.format(TO_FIELD_VAR))
+        request.user = AnonymousUser()
         site = AdminSite()
         admin_register_all(site)
         form_class = movenodeform_factory(model)
@@ -2558,10 +2609,16 @@ class TestAdminTreeList(TestNonEmptyTree):
         m = admin_class(model, site)
         list_display = m.get_list_display(request)
         list_display_links = m.get_list_display_links(request, list_display)
-        cl = ChangeList(request, model, list_display, list_display_links,
-                        m.list_filter, m.date_hierarchy, m.search_fields,
-                        m.list_select_related, m.list_per_page,
-                        m.list_max_show_all, m.list_editable, m)
+        if DJANGO_VERSION < (2, 1):
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m)
+        else:
+            cl = ChangeList(request, model, list_display, list_display_links,
+                            m.list_filter, m.date_hierarchy, m.search_fields,
+                            m.list_select_related, m.list_per_page,
+                            m.list_max_show_all, m.list_editable, m, None)
         cl.formset = None
         context = Context({'cl': cl,
                            'request': request})