[Python-modules-commits] r30062 - in packages/python-django-registration/trunk/debian (6 files)
hertzog at users.alioth.debian.org
hertzog at users.alioth.debian.org
Wed Aug 6 22:02:44 UTC 2014
Date: Wednesday, August 6, 2014 @ 22:02:43
Author: hertzog
Revision: 30062
* Fix and enable the test suite with fix-testsuite.patch. Ensure
it works with Django 1.6.
* Apply two patches for Django 1.7 compatibility:
- django-1.7-compat.patch grabbed in an upstream pull request
- more-django-1.7-fixes.patch authored by myself
Closes: #755653
Added:
packages/python-django-registration/trunk/debian/patches/django-1.7-compat.patch
packages/python-django-registration/trunk/debian/patches/fix-test-suite.patch
packages/python-django-registration/trunk/debian/patches/more-django-1.7-fixes.patch
Modified:
packages/python-django-registration/trunk/debian/changelog
packages/python-django-registration/trunk/debian/patches/series
packages/python-django-registration/trunk/debian/rules
Modified: packages/python-django-registration/trunk/debian/changelog
===================================================================
--- packages/python-django-registration/trunk/debian/changelog 2014-08-06 11:41:33 UTC (rev 30061)
+++ packages/python-django-registration/trunk/debian/changelog 2014-08-06 22:02:43 UTC (rev 30062)
@@ -1,3 +1,14 @@
+python-django-registration (1.0+dfsg-2) unstable; urgency=medium
+
+ * Fix and enable the test suite with fix-testsuite.patch. Ensure
+ it works with Django 1.6.
+ * Apply two patches for Django 1.7 compatibility:
+ - django-1.7-compat.patch grabbed in an upstream pull request
+ - more-django-1.7-fixes.patch authored by myself
+ Closes: #755653
+
+ -- Raphaël Hertzog <hertzog at debian.org> Wed, 06 Aug 2014 23:46:28 +0200
+
python-django-registration (1.0+dfsg-1) unstable; urgency=medium
* Drop David Spreen from Uploaders. Closes: #738931
Added: packages/python-django-registration/trunk/debian/patches/django-1.7-compat.patch
===================================================================
--- packages/python-django-registration/trunk/debian/patches/django-1.7-compat.patch (rev 0)
+++ packages/python-django-registration/trunk/debian/patches/django-1.7-compat.patch 2014-08-06 22:02:43 UTC (rev 30062)
@@ -0,0 +1,58 @@
+Description: Fix for Django 1.7
+ With Django 1.7, the call to get_user_model() triggers
+ django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
+Author: Victor Bornov
+Origin: other, https://bitbucket.org/bornov/django-registration/commits/3c1810ac88aad1569d0a288636803f93fef0b42c
+Bug: https://bitbucket.org/ubernostrum/django-registration/pull-request/88/made-call-to-user-lazy-for-django-17-app/diff
+Bug-Debian: http://bugs.debian.org/755653
+Last-Update: 2014-08-06
+
+diff --git a/registration/models.py b/registration/models.py
+--- a/registration/models.py
++++ b/registration/models.py
+@@ -4,17 +4,12 @@
+ import re
+
+ from django.conf import settings
+-from django.contrib.auth.models import User
+ from django.db import models
+ from django.db import transaction
+ from django.template.loader import render_to_string
+ from django.utils.translation import ugettext_lazy as _
++from django.contrib.auth import get_user_model
+
+-try:
+- from django.contrib.auth import get_user_model
+- User = get_user_model()
+-except ImportError:
+- from django.contrib.auth.models import User
+
+ try:
+ from django.utils.timezone import now as datetime_now
+@@ -81,6 +76,8 @@
+ user. To disable this, pass ``send_email=False``.
+
+ """
++ User = get_user_model()
++
+ new_user = User.objects.create_user(username, email, password)
+ new_user.is_active = False
+ new_user.save()
+@@ -151,6 +148,8 @@
+ be deleted.
+
+ """
++ User = get_user_model()
++
+ for profile in self.all():
+ try:
+ if profile.activation_key_expired():
+@@ -179,7 +178,7 @@
+ """
+ ACTIVATED = u"ALREADY_ACTIVATED"
+
+- user = models.ForeignKey(User, unique=True, verbose_name=_('user'))
++ user = models.ForeignKey(settings.AUTH_USER_MODEL, unique=True, verbose_name=_('user'))
+ activation_key = models.CharField(_('activation key'), max_length=40)
+
+ objects = RegistrationManager()
Added: packages/python-django-registration/trunk/debian/patches/fix-test-suite.patch
===================================================================
--- packages/python-django-registration/trunk/debian/patches/fix-test-suite.patch (rev 0)
+++ packages/python-django-registration/trunk/debian/patches/fix-test-suite.patch 2014-08-06 22:02:43 UTC (rev 30062)
@@ -0,0 +1,112 @@
+Description: Fix the test suite
+ Add files required to run the test suite and also
+ fix some problems in the test suite.
+Author: Raphaël Hertzog <hertzog at debian.org>
+Origin: vendor
+Last-Update: 2014-08-06
+
+---
+The information above should follow the Patch Tagging Guidelines, please
+checkout http://dep.debian.net/deps/dep3/ to learn about the format.
+--- /dev/null
++++ b/registration/tests/settings.py
+@@ -0,0 +1,33 @@
++import os
++
++SECRET_KEY = 'auieanuisetnauisetnauitseauieauie'
++
++SITE_ID = 1
++
++DATABASES = {
++ 'default': {
++ 'ENGINE': 'django.db.backends.sqlite3',
++ 'NAME': 'test.db',
++ }
++}
++
++INSTALLED_APPS = (
++ 'django.contrib.sites',
++ 'django.contrib.contenttypes',
++ 'django.contrib.auth',
++ 'django.contrib.sessions',
++ 'registration',
++)
++
++ROOT_URLCONF = 'registration.tests.urls'
++
++TEMPLATE_DIRS = (
++ os.path.join(os.path.dirname(__file__), 'templates'),
++)
++
++ACCOUNT_ACTIVATION_DAYS = 7
++
++MIDDLEWARE_CLASSES = (
++ 'django.contrib.sessions.middleware.SessionMiddleware',
++ 'django.contrib.auth.middleware.AuthenticationMiddleware',
++)
+--- a/registration/tests/default_backend.py
++++ b/registration/tests/default_backend.py
+@@ -195,4 +195,4 @@ class DefaultBackendViewTests(TestCase):
+
+ self.assertEqual(200, resp.status_code)
+ self.assertTemplateUsed(resp, 'registration/activate.html')
+- self.failIf('activation_key' in resp.context)
++ self.assertTrue('activation_key' in resp.context)
+--- a/registration/tests/models.py
++++ b/registration/tests/models.py
+@@ -1,5 +1,6 @@
+ import datetime
+ import re
++import hashlib
+
+ from django.conf import settings
+ from django.contrib.auth.models import User
+@@ -7,7 +8,6 @@ from django.contrib.sites.models import
+ from django.core import mail
+ from django.core import management
+ from django.test import TestCase
+-from django.utils.hashcompat import sha_constructor
+
+ from registration.models import RegistrationProfile
+
+@@ -183,7 +183,7 @@ class RegistrationModelTests(TestCase):
+ """
+ # Due to the way activation keys are constructed during
+ # registration, this will never be a valid key.
+- invalid_key = sha_constructor('foo').hexdigest()
++ invalid_key = hashlib.sha1('foo').hexdigest()
+ self.failIf(RegistrationProfile.objects.activate_user(invalid_key))
+
+ def test_expired_user_deletion(self):
+--- /dev/null
++++ b/registration/tests/templates/registration/activation_complete.html
+@@ -0,0 +1 @@
++Yay!
+--- /dev/null
++++ b/registration/tests/templates/registration/activate.html
+@@ -0,0 +1 @@
++Too bad. Bad key. {{ activation_key }}
+--- /dev/null
++++ b/registration/tests/templates/registration/activation_email_subject.txt
+@@ -0,0 +1 @@
++Click here to confirm: {{ activation_key }}
+--- /dev/null
++++ b/registration/tests/templates/registration/registration_form.html
+@@ -0,0 +1,5 @@
++<html>
++<body>
++ {{ form }}
++</body>
++</html>
+--- /dev/null
++++ b/registration/tests/templates/registration/activation_email.txt
+@@ -0,0 +1 @@
++Click here to confirm: {{ activation_key }}
+--- /dev/null
++++ b/registration/tests/templates/registration/registration_complete.html
+@@ -0,0 +1 @@
++Yay!
+--- /dev/null
++++ b/registration/tests/templates/registration/registration_closed.html
+@@ -0,0 +1 @@
++No registration, sorry.
Added: packages/python-django-registration/trunk/debian/patches/more-django-1.7-fixes.patch
===================================================================
--- packages/python-django-registration/trunk/debian/patches/more-django-1.7-fixes.patch (rev 0)
+++ packages/python-django-registration/trunk/debian/patches/more-django-1.7-fixes.patch 2014-08-06 22:02:43 UTC (rev 30062)
@@ -0,0 +1,91 @@
+Description: More test suite fixes for Django 1.7
+Author: Raphaël Hertzog <hertzog at 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 at 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 at example.com')
Modified: packages/python-django-registration/trunk/debian/patches/series
===================================================================
--- packages/python-django-registration/trunk/debian/patches/series 2014-08-06 11:41:33 UTC (rev 30061)
+++ packages/python-django-registration/trunk/debian/patches/series 2014-08-06 22:02:43 UTC (rev 30062)
@@ -1 +1,4 @@
send_signal_only_once_when_activating_user.patch
+fix-test-suite.patch
+django-1.7-compat.patch
+more-django-1.7-fixes.patch
Modified: packages/python-django-registration/trunk/debian/rules
===================================================================
--- packages/python-django-registration/trunk/debian/rules 2014-08-06 11:41:33 UTC (rev 30061)
+++ packages/python-django-registration/trunk/debian/rules 2014-08-06 22:02:43 UTC (rev 30062)
@@ -18,3 +18,6 @@
dh_auto_install
# Drop .po files and keep only .mo files (compiled)
find debian/$(PKG)/ -name '*.po' -exec rm {} \;
+
+override_dh_auto_test:
+ PYTHONPATH=. DJANGO_SETTINGS_MODULE=registration.tests.settings python /usr/bin/django-admin test registration.tests
More information about the Python-modules-commits
mailing list