Fakultas Ilmu Komputer UI

Commit 79c4c0c3 authored by Syahrul Ardiansyah's avatar Syahrul Ardiansyah
Browse files

Fix test

parent ad5f4849
Pipeline #25792 passed with stage
in 1 minute and 40 seconds
from django.test import TestCase
from django.contrib.auth import get_user_model
from django.contrib import auth
from accounts.models import Token
User = get_user_model()
User = auth.get_user_model()
class UserModelTest(TestCase):
......@@ -11,19 +11,17 @@ from accounts.models import Token
def send_login_email(request):
email = request.POST['email']
# uid = str(uuid.uuid4())
token = Token.objects.create(email=email)
url = request.build_absolute_uri(
reverse('login') + '?token=' + str(token.uid)
message_body = f'Use this link to log in:\n\n{url}'
message_body = 'Use this link to log in:\n\n%s' % url
'Your login link for Superlists',
# return render(request, 'login_email_sent.html')
"Check your email, we've sent you a link you can use to log in."
......@@ -35,10 +33,6 @@ def login(request):
user = auth.authenticate(uid=request.GET.get('token'))
if user:
auth.login(request, user)
# uid = request.GET.get('uid')
# user = authenticate(uid=uid)
# if user is not None:
# auth_login(request, user)
return redirect('/')
......@@ -31,7 +31,7 @@ class LoginTest(FunctionalTest):
self.assertIn('Use this link to log in', email.body)
url_search = re.search(r'http://.+/.+$', email.body)
if not url_search:
self.fail(f'Could not find url in email body:\n{email.body}')
self.fail('Could not find url in email body:\n%s' % email.body)
url = url_search.group(0)
self.assertIn(self.live_server_url, url)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment