Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TestAuthUser(TestCase):
- username, password = 'testuser', '123'
- def setUp(self):
- self.user = User.objects.create(username=self.username)
- self.user.set_password(self.password)
- self.user.save()
- def test_posts_list_NOT_authenticated_user(self):
- response = self.client.get('/posts/')
- self.assertEqual('<h1>List</h1>', response.content.decode())
- def test_posts_list_authenticated_user(self):
- logged_in = self.client.login(username=self.username, password=self.password)
- self.assertTrue(logged_in)
- response = self.client.get('/posts/')
- self.assertEqual('<h1>My List</h1>', response.content.decode())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement