I have below code and looking for simple unitest to cover it.
I'm not sure if it is possible to write uni test without real online login into google.
from django.http import HttpResponse
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
from allauth.exceptions import ImmediateHttpResponse
from kano_konnect.settings import ALLOWED_DOMAIN, ALLOWED_DOMAIN_2
class KcSocialAccountAdapter(DefaultSocialAccountAdapter):
def pre_social_login(self, request, sociallogin):
email_domain = sociallogin.user.email.split('@')[1].lower()
if email_domain not in (ALLOWED_DOMAIN, ALLOWED_DOMAIN_2):
raise ImmediateHttpResponse(
HttpResponse(
sociallogin.user.email +
' is not valid memeber of ' +
ALLOWED_DOMAIN +
' or ' +
ALLOWED_DOMAIN_2))
Aucun commentaire:
Enregistrer un commentaire