Fakultas Ilmu Komputer UI

Commit ad617b03 authored by Usman Sidiq's avatar Usman Sidiq
Browse files

[RED] adding test for email activation

parent 208c3737
Pipeline #45288 passed with stages
in 14 minutes and 56 seconds
......@@ -5,7 +5,9 @@ from rest_framework import status
from django.test import TestCase, SimpleTestCase, Client
from django.urls import include, path, reverse
from registrasi.models import BisaGoUser
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
from .tokens import account_activation_token
from django.utils.encoding import force_bytes, force_text
class UserTests(APITestCase):
urlpatterns = [
......@@ -17,8 +19,7 @@ class UserTests(APITestCase):
data = {'name': 'Astraykai',
'email':'astraykai@gmail.com',
'phone_number':'089892218567',
'password':'chingchenghanji',
'is_active': True}
'password':'chingchenghanji'}
self.client.post(url, data)
def test_create_user(self):
......@@ -94,6 +95,22 @@ class UserTests(APITestCase):
def test_account_login(self):
pass
def test_without_verification(self):
url = reverse('api-token-auth')
data = {'username': 'astraykai@gmail.com',
'password':'chingchenghanji'}
response = self.client.post(url, data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_activation_function(self):
user = BisaGoUser.objects.get(phone_number='089892218567').user
uid = urlsafe_base64_encode(force_bytes(user.pk)).decode()
token = account_activation_token.make_token(user)
url = reverse('activate', kwargs={'uidb64' : uid, 'token' : token})
response = self.client.get(url)
json_response = json.loads(response.content)
self.assertEqual(json_response['response'], 'User activated')
class InfoTests(APITestCase, URLPatternsTestCase):
pass
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