parent
b8478ea2c8
commit
de2d95201a
5 changed files with 41 additions and 3 deletions
@ -0,0 +1,20 @@ |
|||||||
|
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']) |
||||||
Loading…
Reference in new issue