File: more-django-1.7-fixes.patch

package info (click to toggle)
python-django-registration 1.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 704 kB
  • ctags: 306
  • sloc: python: 876; makefile: 84
file content (91 lines) | stat: -rw-r--r-- 3,839 bytes parent folder | 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
Description: More test suite fixes for Django 1.7
Author: Raphaƫl Hertzog <hertzog@debian.org>
Origin: vendor
Bug-Debian: http://bugs.debian.org/755653
Last-Update: 2014-08-06
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/registration/backends/simple/urls.py
+++ b/registration/backends/simple/urls.py
@@ -32,5 +32,8 @@ urlpatterns = patterns('',
                        url(r'^register/closed/$',
                            TemplateView.as_view(template_name='registration/registration_closed.html'),
                            name='registration_disallowed'),
+                       url(r'^register/complete/$',
+                           TemplateView.as_view(template_name='registration/registration_complete.html'),
+                           name='registration_complete'),
                        (r'', include('registration.auth_urls')),
                        )
--- a/registration/backends/simple/views.py
+++ b/registration/backends/simple/views.py
@@ -42,4 +42,4 @@ class RegistrationView(BaseRegistrationV
         return getattr(settings, 'REGISTRATION_OPEN', True)
 
     def get_success_url(self, request, user):
-        return (user.get_absolute_url(), (), {})
+        return ('registration_complete', (), {})
--- a/registration/tests/default_backend.py
+++ b/registration/tests/default_backend.py
@@ -6,6 +6,10 @@ from django.contrib.sites.models import
 from django.core import mail
 from django.core.urlresolvers import reverse
 from django.test import TestCase
+try:
+    from django.test.utils import override_settings
+except:
+    from django.test import override_settings
 
 from registration import signals
 from registration.admin import RegistrationAdmin
@@ -113,15 +117,24 @@ class DefaultBackendViewTests(TestCase):
         self.assertEqual(RegistrationProfile.objects.count(), 1)
         self.assertEqual(len(mail.outbox), 1)
 
+    @override_settings(INSTALLED_APPS=
+                       ('django.contrib.contenttypes',
+                        'django.contrib.auth',
+                        'django.contrib.sessions',
+                        'registration',))
     def test_registration_no_sites(self):
         """
         Registration still functions properly when
         ``django.contrib.sites`` is not installed; the fallback will
         be a ``RequestSite`` instance.
-        
-        """
-        Site._meta.installed = False
 
+        """
+        try:
+            # Django 1.7 does it correctly
+            self.assertFalse(Site._meta.installed)
+        except:
+            # For older versions we fake it and restore it at the end
+            Site._meta.installed = False
         resp = self.client.post(reverse('registration_register'),
                                 data={'username': 'bob',
                                       'email': 'bob@example.com',
@@ -139,7 +152,11 @@ class DefaultBackendViewTests(TestCase):
         self.assertEqual(RegistrationProfile.objects.count(), 1)
         self.assertEqual(len(mail.outbox), 1)
 
-        Site._meta.installed = True
+        try:
+            # Raises an exception with Django 1.7 as attribute is read-only
+            Site._meta.installed = True
+        except AttributeError:
+            pass
 
     def test_registration_failure(self):
         """
--- a/registration/tests/simple_backend.py
+++ b/registration/tests/simple_backend.py
@@ -63,7 +63,7 @@ class SimpleBackendViewTests(TestCase):
 
         new_user = User.objects.get(username='bob')
         self.assertEqual(302, resp.status_code)
-        self.failUnless(new_user.get_absolute_url() in resp['Location'])
+        self.failUnless(reverse('registration_complete') in resp['Location'])
 
         self.failUnless(new_user.check_password('secret'))
         self.assertEqual(new_user.email, 'bob@example.com')