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.
20 lines
745 B
20 lines
745 B
from django.contrib.auth import get_user_model
|
|
from django.test import TestCase, Client
|
|
from django.urls import reverse
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
class LoginTest(TestCase):
|
|
def setUp(self):
|
|
self.url = reverse("lilcity:login")
|
|
self.user = User.objects.create_user(username='Alice', password='1234')
|
|
self.client = Client()
|
|
|
|
def test_login(self):
|
|
response = self.client.post(self.url, {"username": self.user.username, "password": '1234'})
|
|
self.assertTrue(response.json()['success'])
|
|
|
|
def test_should_errors_if_fail_login(self):
|
|
response = self.client.post(self.url, {"username": self.user.username, "password": 'incorrect password'})
|
|
self.assertFalse(response.json()['success'])
|
|
|