From 73bdbf4040b4b14f6714773121e30c67a6a13c90 Mon Sep 17 00:00:00 2001
From: Dwi Nanda <dwi.nanda@ui.ac.id>
Date: Tue, 17 Sep 2019 21:10:09 +0700
Subject: [PATCH] Basic view now returns minimal HTML

---
 functional_tests.py |  2 +-
 lists/tests.py      | 10 +++++++++-
 lists/views.py      |  5 +++--
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/functional_tests.py b/functional_tests.py
index f721ba5..31d5918 100644
--- a/functional_tests.py
+++ b/functional_tests.py
@@ -10,7 +10,7 @@ class NewVisitorTest(unittest.TestCase):
  # to check out its homepage
         self.browser.get('http://localhost:8000')
  # She notices the page title and header mention to-do lists
-        self.assertIn('To Do', self.browser.title)
+        self.assertIn('To-Do', self.browser.title)
         self.fail('Finish the test!')
  # She is invited to enter a to-do item straight away
 #  [...rest of comments as before]
diff --git a/lists/tests.py b/lists/tests.py
index 2cd3fe1..e4cdd77 100644
--- a/lists/tests.py
+++ b/lists/tests.py
@@ -1,7 +1,15 @@
 from django.urls import resolve
 from django.test import TestCase
+from django.http import HttpRequest
 from lists.views import home_page
 class HomePageTest(TestCase):
     def test_root_url_resolves_to_home_page_view(self):
         found = resolve('/')
-        self.assertEqual(found.func, home_page)
\ No newline at end of file
+        self.assertEqual(found.func, home_page)
+    def test_home_page_returns_correct_html(self):
+        request = HttpRequest()
+        response = home_page(request)
+        html = response.content.decode('utf8')
+        self.assertTrue(html.startswith('<html>'))
+        self.assertIn('<title>To-Do lists</title>', html)
+        self.assertTrue(html.endswith('</html>')) 
\ No newline at end of file
diff --git a/lists/views.py b/lists/views.py
index 5623c95..6d9257d 100644
--- a/lists/views.py
+++ b/lists/views.py
@@ -1,5 +1,6 @@
 from django.shortcuts import render
+from django.http import HttpResponse
 # Create your views here.
 
-def home_page():
-    pass
\ No newline at end of file
+def home_page(req):
+    return HttpResponse('<html><title>To-Do lists</title></html>')
\ No newline at end of file
-- 
GitLab