Skip to content

Commit

Permalink
Revising tests for DUA removal.
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamu committed Apr 15, 2016
1 parent dd1010c commit cea420b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 11 additions & 4 deletions pinax/likes/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import mock

from django.conf import settings
from django.contrib.auth.models import AnonymousUser, User
from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse
Expand Down Expand Up @@ -37,6 +38,15 @@ def setUp(self):

)

self.login_redirect = settings.LOGIN_URL

def assertRedirectsToLogin(self, response, next):
self.assertRedirects(
response,
"{}?next={}".format(self.login_redirect, next),
fetch_redirect_response=False
)

def test_like_brian(self):
"""
Ensure logged-in user can like another user.
Expand Down Expand Up @@ -86,10 +96,7 @@ def test_unauthed_like_brian(self):
content_type_id=self.user_content_type.pk,
object_id=brian.pk
)
self.assertEqual(response.status_code, 302)
encoded_url = urlquote(url)
# Response (redirect) URL path comes from pinax/likes/tests/urls.py
self.assertEqual(response.url, "/dummy_login/?next={}".format(encoded_url))
self.assertRedirectsToLogin(response, urlquote(url))
self.assertFalse(self.like_qs.filter(receiver_object_id=brian.pk).exists())

def test_unlike_james(self):
Expand Down
3 changes: 2 additions & 1 deletion pinax/likes/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.conf.urls import include, url
from django.http import HttpResponse


def dummy_view():
pass
return HttpResponse(content=b'', status=200)

urlpatterns = [
url(r"^", include("pinax.likes.urls", namespace="pinax_likes")),
Expand Down
1 change: 1 addition & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"css_class_off": "fa-heart-o"
}
},
LOGIN_URL="/dummy_login/",
AUTHENTICATION_BACKENDS=[
"pinax.likes.auth_backends.CanLikeBackend"
],
Expand Down

0 comments on commit cea420b

Please sign in to comment.