Guest User

Untitled

a guest
Sep 30th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. # tests/test_auth.py
  2. # ...
  3. class AuthenticationTestCase(unittest.TestCase):
  4. # ...
  5. def test_edit_profile_route(self):
  6. u = User(email='john@example.com',
  7. username='john',
  8. password='cat',
  9. confirmed=True)
  10. db.session.add(u)
  11. db.session.commit()
  12. response = self.client.get('/auth/edit-profile/' + str(u.id),
  13. follow_redirects=True)
  14. self.assertEqual(response.status_code, 200)
  15. self.assertIn('Please log in to access this page',
  16. response.get_data(as_text=True))
  17. self.login(u.email, 'cat')
  18. response = self.client.get('/auth/edit-profile/' + str(u.id),
  19. follow_redirects=True)
  20. self.assertEqual(response.status_code, 200)
  21. self.assertIn('Edit Profile',
  22. response.get_data(as_text=True))
  23. response = self.client.post('/auth/edit-profile/' + str(u.id),
  24. data={
  25. 'name': 'John Smith',
  26. 'age': 36,
  27. 'location': 'London, UK',
  28. 'bio': 'Short Bio'},
  29. follow_redirects=True)
  30. self.assertEqual(response.status_code, 200)
  31. self.assertIn('John Smith', response.get_data(as_text=True))
  32. self.assertIn('36', response.get_data(as_text=True))
  33. self.assertIn('London, UK', response.get_data(as_text=True))
  34. self.assertIn('Short Bio', response.get_data(as_text=True))
Add Comment
Please, Sign In to add comment