Advertisement
Guest User

Untitled

a guest
Jun 9th, 2016
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. class TestAuthUser(TestCase):
  2. username, password = 'testuser', '123'
  3.  
  4. def setUp(self):
  5. self.user = User.objects.create(username=self.username)
  6. self.user.set_password(self.password)
  7. self.user.save()
  8.  
  9. def test_posts_list_NOT_authenticated_user(self):
  10. response = self.client.get('/posts/')
  11. self.assertEqual('<h1>List</h1>', response.content.decode())
  12.  
  13. def test_posts_list_authenticated_user(self):
  14. logged_in = self.client.login(username=self.username, password=self.password)
  15. self.assertTrue(logged_in)
  16. response = self.client.get('/posts/')
  17. self.assertEqual('<h1>My List</h1>', response.content.decode())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement