tests.py 630 B

123456789101112131415161718192021
  1. from django.urls import resolve
  2. from django.test import TestCase
  3. from django.http import HttpRequest
  4. from lists.views import home_page
  5. class HomePageTest(TestCase):
  6. def test_root_url_resolves_to_home_page_view(self):
  7. found = resolve('/')
  8. self.assertEqual(found.func, home_page)
  9. def test_home_page_returns_correct_html(self):
  10. request = HttpRequest()
  11. response = home_page(request)
  12. html = response.content.decode('utf8')
  13. self.assertTrue(html.startswith('<html>'))
  14. self.assertIn('<title>To-Do lists</title>', html)
  15. self.assertTrue(html.endswith('</html>'))