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
|
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@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.
|