Fakultas Ilmu Komputer UI

Commit d2277fa6 authored by Rayza Arasj Mahardhika's avatar Rayza Arasj Mahardhika
Browse files

basic view now returns minimal HTML

parent 7a095fab
from django.urls import resolve
from django.test import TestCase
from django.http import HttpRequest
from lists.views import home_page
class HomePageTest(TestCase):
......@@ -7,3 +9,11 @@ class HomePageTest(TestCase):
def test_root_url_resolves_to_home_page_view(self):
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>'))
from django.shortcuts import render
from django.http import HttpResponse
def home_page():
pass
def home_page(request):
return HttpResponse('<html><title>To-Do lists</title></html>')
Supports Markdown
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