From cc3fd6f5b463d53ebbc0dd90c0a0d285618b8abf Mon Sep 17 00:00:00 2001
From: Alvin Raihan <alvin.raihan@ui.ac.id>
Date: Wed, 18 Sep 2019 17:48:52 +0700
Subject: [PATCH] ch3

---
 virtualenv/lists/tests.py | 18 +++++++++++++++---
 virtualenv/lists/views.py |  6 +++---
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/virtualenv/lists/tests.py b/virtualenv/lists/tests.py
index f918990f..fe298078 100644
--- a/virtualenv/lists/tests.py
+++ b/virtualenv/lists/tests.py
@@ -1,9 +1,21 @@
 from django.urls import resolve
 from django.test import TestCase
-from lists.views import home_page  
+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
+        found = resolve('/')
+        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/virtualenv/lists/views.py b/virtualenv/lists/views.py
index 444abe40..ec6a9bc3 100644
--- a/virtualenv/lists/views.py
+++ b/virtualenv/lists/views.py
@@ -1,5 +1,5 @@
-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(request):
+    return HttpResponse('<html><title>To-Do lists</title></html>')
\ No newline at end of file
-- 
GitLab