fix unit tests for social auth - required after changes in allauth v0.19.0

This commit is contained in:
Mateusz Sikora 2015-01-09 11:12:00 +01:00
parent ed32f907d9
commit 5d53a0e0a0

View File

@ -12,6 +12,7 @@ from django.test.utils import override_settings
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from allauth.socialaccount.models import SocialApp from allauth.socialaccount.models import SocialApp
from allauth.socialaccount.providers.facebook.provider import GRAPH_API_URL
import responses import responses
from rest_framework import status from rest_framework import status
@ -380,6 +381,7 @@ class TestSocialAuth(TestCase, BaseAPITestCase):
urls = 'rest_auth.test_urls' urls = 'rest_auth.test_urls'
def setUp(self): def setUp(self):
social_app = SocialApp.objects.create( social_app = SocialApp.objects.create(
provider='facebook', provider='facebook',
name='Facebook', name='Facebook',
@ -389,12 +391,13 @@ class TestSocialAuth(TestCase, BaseAPITestCase):
site = Site.objects.get_current() site = Site.objects.get_current()
social_app.sites.add(site) social_app.sites.add(site)
self.fb_login_url = reverse('fb_login') self.fb_login_url = reverse('fb_login')
self.graph_api_url = GRAPH_API_URL + '/me'
@responses.activate @responses.activate
def test_failed_social_auth(self): def test_failed_social_auth(self):
# fake response # fake response
responses.add(responses.GET, 'https://graph.facebook.com/me', responses.add(responses.GET, self.graph_api_url, body='', status=400,
body='', status=400, content_type='application/json') content_type='application/json')
payload = { payload = {
'access_token': 'abc123' 'access_token': 'abc123'
@ -405,8 +408,8 @@ class TestSocialAuth(TestCase, BaseAPITestCase):
def test_social_auth(self): def test_social_auth(self):
# fake response for facebook call # fake response for facebook call
resp_body = '{"id":"123123123123","first_name":"John","gender":"male","last_name":"Smith","link":"https:\\/\\/www.facebook.com\\/john.smith","locale":"en_US","name":"John Smith","timezone":2,"updated_time":"2014-08-13T10:14:38+0000","username":"john.smith","verified":true}' resp_body = '{"id":"123123123123","first_name":"John","gender":"male","last_name":"Smith","link":"https:\\/\\/www.facebook.com\\/john.smith","locale":"en_US","name":"John Smith","timezone":2,"updated_time":"2014-08-13T10:14:38+0000","username":"john.smith","verified":true}'
responses.add(responses.GET, 'https://graph.facebook.com/me', responses.add(responses.GET, self.graph_api_url, body=resp_body,
body=resp_body, status=200, content_type='application/json') status=200, content_type='application/json')
payload = { payload = {
'access_token': 'abc123' 'access_token': 'abc123'