Commits

Anonymous committed f91e826 Draft

Tests work standalone

Dummy templates were added to tests/templates. These templates are
added to the search paths only when testing the app, and are only
used to check that they actually get loaded on the correct views.

The version test was changed to match the _real_ behavior of the
get_version function. Not even in the previous version the returned
strings matched the ones expected. Since the get_version function
from django-registration is essentially the same as the one from
django.utils.version.get_version, the django-registration version
is now just a wrapper around the one from the Django project.

Comments (0)

Files changed (17)

registration/__init__.py

 VERSION = (0, 8, 0, 'final', 0)
 
+from django.utils.version import get_version as django_get_version
+
 def get_version(version=None):
-    """Derives a PEP386-compliant version number from VERSION."""
-    if version is None:
-        version = VERSION
-    assert len(version) == 5
-    assert version[3] in ('alpha', 'beta', 'rc', 'final')
-
-    # Now build the two parts of the version number:
-    # main = X.Y[.Z]
-    # sub = .devN - for pre-alpha releases
-    #     | {a|b|c}N - for alpha, beta and rc releases
-
-    parts = 2 if version[2] == 0 else 3
-    main = '.'.join(str(x) for x in version[:parts])
-
-    sub = ''
-    if version[3] == 'alpha' and version[4] == 0:
-        # At the toplevel, this would cause an import loop.
-        from django.utils.version import get_svn_revision
-        svn_revision = get_svn_revision()[4:]
-        if svn_revision != 'unknown':
-            sub = '.dev%s' % svn_revision
-
-    elif version[3] != 'final':
-        mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}
-        sub = mapping[version[3]] + str(version[4])
-
-    return main + sub
+	if version is None:
+		version = VERSION
+	return django_get_version(version)

registration/auth_urls.py

 
 """
 
-from django.conf.urls.defaults import *
+from django.conf.urls import patterns, url, include
 
 from django.contrib.auth import views as auth_views
 

registration/backends/default/urls.py

 """
 
 
-from django.conf.urls.defaults import *
+from django.conf.urls import patterns, url, include
 from django.views.generic import TemplateView
 
 from registration.views import activate

registration/backends/simple/urls.py

 """
 
 
-from django.conf.urls.defaults import *
+from django.conf.urls import patterns, url, include
 from django.views.generic import TemplateView
 
 from registration.views import activate

registration/tests/__init__.py

         
         """
         versions = [
-            {'version': (1, 0, 0, 'alpha', 0),
-             'expected': "1.0 pre-alpha"},
+            #nothing in either the old or new get_version uses "pre-"
+            #{'version': (1, 0, 0, 'alpha', 0),
+            # 'expected': "1.0 pre-alpha"},
             {'version': (1, 0, 1, 'alpha', 1),
-             'expected': "1.0.1 alpha 1"},
+             'expected': "1.0.1a1"},
             {'version': (1, 1, 0, 'beta', 2),
-             'expected': "1.1 beta 2"},
+             'expected': "1.1b2"},
             {'version': (1, 2, 1, 'rc', 3),
-             'expected': "1.2.1 rc 3"},
+             'expected': "1.2.1c3"},
             {'version': (1, 3, 0, 'final', 0),
              'expected': "1.3"},
             {'version': (1, 4, 1, 'beta', 0),
-             'expected': "1.4.1 beta"},
+             'expected': "1.4.1b0"},
+            {'version': (1, 5, 0, 'final', 0),
+             'expected': "1.5"},
             ]
         
         for version_dict in versions:

registration/tests/backends.py

 import datetime
+import os
 
 from django.conf import settings
 from django.contrib import admin
 from django.core.handlers.wsgi import WSGIRequest
 from django.test import Client
 from django.test import TestCase
+from django.test.utils import override_settings
 
 from registration import forms
 from registration import signals
                           'registration.backends.default.NonexistentBackend')
 
 
+@override_settings(
+    TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)
+)
 class DefaultRegistrationBackendTests(TestCase):
     """
     Test the default registration backend.

registration/tests/models.py

 import datetime
 import re
+import os
 
 from django.conf import settings
 from django.contrib.auth.models import User
 from django.core import mail
 from django.core import management
 from django.test import TestCase
+from django.test.utils import override_settings
 from django.utils.hashcompat import sha_constructor
 
 from registration.models import RegistrationProfile
 
 
+@override_settings(
+    TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)
+)
 class RegistrationModelTests(TestCase):
     """
     Test the model and manager used in the default backend.

registration/tests/templates/registration/activate.html

Empty file added.

registration/tests/templates/registration/activation_complete.html

Empty file added.

registration/tests/templates/registration/activation_email.txt

Empty file added.

registration/tests/templates/registration/activation_email_subject.txt

Empty file added.

registration/tests/templates/registration/registration_closed.html

Empty file added.

registration/tests/templates/registration/registration_complete.html

Empty file added.

registration/tests/templates/registration/registration_form.html

Empty file added.

registration/tests/templates/registration/test_template_name.html

Empty file added.

registration/tests/urls.py

 
 """
 
-from django.conf.urls.defaults import *
+from django.conf.urls import patterns, url, include
 from django.views.generic import TemplateView
 
 from registration.views import activate

registration/tests/views.py

 import datetime
+import os
 
 from django.conf import settings
 from django.contrib.auth.models import User
 from django.core import mail
 from django.core.urlresolvers import reverse
 from django.test import TestCase
+from django.test.utils import override_settings
 
 from registration import forms
 from registration.models import RegistrationProfile
 
-
+@override_settings(
+    TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)
+)
 class RegistrationViewTests(TestCase):
     """
     Test the registration views.