Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
fix provider for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreJunod committed Dec 20, 2023
1 parent 274fdd8 commit db3a7cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import base64
import hashlib

# import allauth.app_settings
from urllib.parse import parse_qs, urlparse

import requests
from allauth.socialaccount.tests import MockedResponse, OAuth2TestsMixin


class CostumOAuth2TestsMixin(OAuth2TestsMixin):
class CustomOAuth2TestsMixin(OAuth2TestsMixin):
"""
Override from OAuth2TestsMixin login method to fix error at args[0] == "POST"
https://github.com/pennersr/django-allauth/blob/main/allauth/socialaccount/tests/__init__.py
"""

# TODO: PKCE is set at false manually. Need to remove this method, and try to fix test with another solution
# Override from OAuth2TestsMixin.login https://github.com/pennersr/django-allauth/blob/main/allauth/socialaccount/tests/__init__.py
def login(self, resp_mock=None, process="login", with_refresh_token=True):

with self.mocked_response():
Expand Down
4 changes: 2 additions & 2 deletions geocity/tests/accounts/test_oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.urls import reverse

from geocity.apps.accounts.geomapfish.provider import GeomapfishProvider
from geocity.tests.accounts.costum_oauth2_test_mixin import CostumOAuth2TestsMixin
from geocity.tests.accounts.custom_oauth2_test_mixin import CustomOAuth2TestsMixin

User = get_user_model()

Expand Down Expand Up @@ -49,7 +49,7 @@
}


class GeomapfishOAuth2Tests(CostumOAuth2TestsMixin, TestCase):
class GeomapfishOAuth2Tests(CustomOAuth2TestsMixin, TestCase):
provider_id = GeomapfishProvider.id

def get_mocked_response(self, email="[email protected]", username="test"):
Expand Down
10 changes: 5 additions & 5 deletions geocity/tests/accounts/test_oauth2_dootix.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import json

from allauth.tests import MockedResponse, TestCase
from django.contrib.auth import get_user_model
from django.urls import reverse

from geocity.tests.accounts.costum_oauth2_test_mixin import CostumOAuth2TestsMixin

User = get_user_model()
from geocity.apps.accounts.dootix.provider import DootixProvider
from geocity.tests.accounts.custom_oauth2_test_mixin import CustomOAuth2TestsMixin

# Dootix profile_url success response mock.
# Happen if login succeeded.
Expand All @@ -23,11 +21,13 @@
}


class DootixOAuth2Tests(CostumOAuth2TestsMixin, TestCase):
class DootixOAuth2Tests(CustomOAuth2TestsMixin, TestCase):
"""
Default OAuth2 automated tests + dootix specific tests.
"""

provider_id = DootixProvider.id

def get_mocked_response(self, email="[email protected]"):
profile_response_mock.update(
{
Expand Down

0 comments on commit db3a7cb

Please sign in to comment.