Commit 0a7d0800 authored by Alex Bernard Francia's avatar Alex Bernard Francia

Refactored home page unit test. Succesful.

parent 99839ae3
from django.urls import resolve # from django.urls import resolve
from django.test import TestCase from django.test import TestCase
from .views import go_to_home_page # from django.template.loader import render_to_string
# from .views import go_to_home_page
# Create your tests here. # Create your tests here.
class HomePageTest(TestCase): class HomePageTest(TestCase):
def test_root_url_resolves_to_home_page_view(self):
found = resolve('/')
self.assertEqual(found.func, go_to_home_page) def test_home_page_returns_correct_html(self):
\ No newline at end of file response = self.client.get('/')
# html = response.content.decode('utf8')
# expected_html = render_to_string('home_page.html')
# self.assertTrue(html.startswith('<html>'))
# self.assertIn('<title>The Good Place</title>',html)
# self.assertTrue(html.endswith('</html>'))
# self.assertEqual(html, expected_html)
self.assertTemplateUsed(response, 'home_page.html')
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment