diff --git a/djangowind/templates/base.html b/djangowind/templates/base.html new file mode 100644 index 0000000..cb0dbe4 --- /dev/null +++ b/djangowind/templates/base.html @@ -0,0 +1 @@ +{% block content %}{% endblock %} diff --git a/djangowind/tests/test_views.py b/djangowind/tests/test_views.py index 5fc9936..0abc3d1 100644 --- a/djangowind/tests/test_views.py +++ b/djangowind/tests/test_views.py @@ -1,8 +1,12 @@ -from __future__ import unicode_literals - from django.test import TestCase +from django.test.client import Client + +class TestLoginView(TestCase): + def setUp(self): + self.c = Client() -class DummyTest(TestCase): - def test_nothing(self): - self.assertTrue(1 == 1) + def test_logged_out(self): + r = self.c.get("/accounts/login/") + self.assertEqual(r.status_code, 200) + self.assertTrue('cas_base' in r.context) diff --git a/djangowind/tests/urls.py b/djangowind/tests/urls.py new file mode 100644 index 0000000..e946f2a --- /dev/null +++ b/djangowind/tests/urls.py @@ -0,0 +1,5 @@ +from django.conf.urls import include, url + +urlpatterns = [ + url(r'^accounts/', include('djangowind.urls')), +] diff --git a/djangowind/views.py b/djangowind/views.py index 57be579..a712542 100644 --- a/djangowind/views.py +++ b/djangowind/views.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals from django.http import HttpResponseRedirect, HttpResponseForbidden -from django.shortcuts import render_to_response +from django.shortcuts import render from django.contrib.auth import authenticate from django.contrib.auth import login as django_login @@ -11,7 +11,6 @@ from django.contrib.sites.models import Site from django.contrib.auth.forms import AuthenticationForm -from django.template import RequestContext try: from django.contrib.sites.requests import RequestSite except ImportError: @@ -76,7 +75,7 @@ def login(request, template_name='registration/login.html', else: current_site = RequestSite(request) - return render_to_response(template_name, { + return render(request, template_name, { 'form': form, redirect_field_name: redirect_to, 'site_name': current_site.name, @@ -84,7 +83,7 @@ def login(request, template_name='registration/login.html', 'wind_base': get_wind_base(), 'cas_base': get_cas_base(), 'wind_service': get_wind_service(), - }, context_instance=RequestContext(request)) + }) login = never_cache(login) diff --git a/runtests.py b/runtests.py index 4177803..e067e50 100644 --- a/runtests.py +++ b/runtests.py @@ -22,20 +22,43 @@ def main(): 'django.contrib.messages.middleware.MessageMiddleware', ), INSTALLED_APPS=( + 'django.contrib.sites', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'djangowind', 'django_jenkins', ), + SITE_ID=1, JENKINS_TEST_RUNNER = 'django_jenkins.runner.CITestSuiteRunner', TEST_RUNNER='django.test.runner.DiscoverRunner', + TEMPLATES=[ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + # insert your TEMPLATE_DIRS here + ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.template.context_processors.tz', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, + ], + TEST_PROJECT_APPS = ( 'djangowind', ), COVERAGE_EXCLUDES_FOLDERS = ['migrations'], - ROOT_URLCONF = [], + ROOT_URLCONF = 'djangowind.tests.urls', SOUTH_TESTS_MIGRATE=False, PROJECT_APPS = [