Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- This file demonstrates writing tests using the unittest module. These will pass
- when you run "manage.py test".
- Replace this with more appropriate tests for your application.
- """
- from django.test import TestCase
- from django.contrib.auth.models import User
- from django.test.client import Client
- class LoginTest(TestCase):
- def test_login_fail(self):
- user = User.objects.create_user('testuser', 'test@test.com', 'test123')
- client = Client()
- response = client.post('/login/', {'username' : 'test' , 'password' : 'test' })
- # will display html content when running test print response.content
- self.assertFormError(response, 'form', None, 'Username and password do not match')
- def test_login_success(self):
- user = User.objects.create_user('testuser', 'test@test.com', 'test123')
- client = Client()
- response = self.client.post(dict(username='testuers', password='test123')
- self.assertRedirects(response. '/')
Add Comment
Please, Sign In to add comment