Skip to content

Commit

Permalink
fix(test): breakage with django-allauth 0.62.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gekoke committed Apr 27, 2024
1 parent 77e5bbd commit cfaa9f6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dj_rest_auth/tests/test_serializers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@

from allauth.socialaccount.providers.facebook.views import FacebookOAuth2Adapter
from allauth.socialaccount.providers.facebook.views import FacebookProvider
from allauth.socialaccount.providers.facebook.provider import FacebookProvider
from allauth.socialaccount.models import SocialApp
from allauth.core.exceptions import ImmediateHttpResponse
from django.contrib.auth import get_user_model
from django.urls import reverse
from django.core.exceptions import ValidationError
from django.test import TestCase, modify_settings, override_settings
from django.contrib.sites.models import Site
from django.contrib.sessions.middleware import SessionMiddleware
from django.http import HttpResponseBadRequest
from rest_framework.exceptions import ErrorDetail
from rest_framework.test import APIRequestFactory, force_authenticate
Expand Down Expand Up @@ -119,6 +120,10 @@ class TestSocialLoginSerializer(TestCase):
def setUpTestData(cls):
cls.request_data = {"access_token": "token1234"}
cls.request = APIRequestFactory().post(cls.request_data, format='json')

middleware = SessionMiddleware(get_response=MagicMock())
middleware(cls.request)

social_app = SocialApp.objects.create(
provider='facebook',
name='Facebook',
Expand Down Expand Up @@ -148,7 +153,7 @@ def test_validate_no_adpapter_class_present(self):
serializer.is_valid()
self.assertDictEqual(serializer.errors, self.NO_ADAPTER_CLASS_PRESENT)

@patch('allauth.socialaccount.providers.facebook.views.fb_complete_login')
@patch('allauth.socialaccount.providers.facebook.views.FacebookOAuth2Adapter.complete_login')
@patch('allauth.socialaccount.adapter.DefaultSocialAccountAdapter.pre_social_login')
def test_immediate_http_response_error(self, mock_pre_social_login, mock_fb_complete_login):
dummy_view = SocialLoginView()
Expand Down

0 comments on commit cfaa9f6

Please sign in to comment.