Debian Codegraph @

tests/apps/socialaccount/providers/dummy/tests.py

raw
1 from http import HTTPStatus
2
3 from django.conf import settings
4 from django.contrib.auth import get_user_model
5 from django.urls import reverse
6
7 from allauth.socialaccount.models import SocialAccount
8
9
10 def test_login(client, db):
11 resp = client.post(reverse("dummy_login"))
12 assert resp.status_code == HTTPStatus.FOUND
13 assert resp["location"].startswith(f"{reverse('dummy_authenticate')}?state=")
14 resp = client.post(
15 resp["location"],
16 {"id": "123", "email": "[email protected]", "email_verified": True},
17 )
18 assert resp.status_code == HTTPStatus.FOUND
19 assert resp["location"] == settings.LOGIN_REDIRECT_URL
20 get_user_model().objects.filter(email="[email protected]").exists()
21 socialaccount = SocialAccount.objects.get(uid="123")
22 account = socialaccount.get_provider_account()
23 assert account.to_str() == "[email protected]"