Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit a7688655 authored by Muhammad Ilham Peruzzi's avatar Muhammad Ilham Peruzzi
Browse files

Basic view now returns minimal HTML

parent 06c0666c
Branches testinggoat/ch1-3
No related tags found
No related merge requests found
from django.core.urlresolvers 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)
self.assertTrue(response.content.startswith(b'<html>'))
self.assertIn(b'<title>To-Do lists</title>', response.content)
self.assertTrue(response.content.endswith(b'</html>'))
\ No newline at end of file
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment