You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
1.2 KiB

from django.contrib.auth import get_user_model
from ..tokens import verification_email_token
from django.test import TestCase, Client
from django.urls import reverse
User = get_user_model()
class VerificationEmailTest(TestCase):
def setUp(self):
self.client = Client()
self.user_1 = User.objects.create_user(username='user_1@example.com', password='1234')
self.token_user_1 = verification_email_token.make_token(self.user_1)
self.url = reverse('lilcity:verification-email', kwargs={"token": self.token_user_1})
def test_should_verification_email_for_login_user(self):
self.client.login(username=self.user_1.username, password='1234')
response = self.client.get(f'{self.url}')
self.assertEqual(response.status_code, 200)
def test_should_anonymous_user(self):
response = self.client.get(f'{self.url}')
self.assertEqual(response.status_code, 400)
def test_should_error_if_token_is_not_valid(self):
user_hacker = User.objects.create_user(username='hacker@example.com', password='1234')
self.client.login(username=user_hacker.username, password='1234')
response = self.client.get(f'{self.url}')
self.assertEqual(response.status_code, 400)