First unit test and view function
This commit is contained in:
parent
e373ec5d69
commit
285725ffdd
@ -1,6 +1,13 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from django.http import HttpRequest
|
||||||
|
from lists.views import home_page
|
||||||
|
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
class SmokeTest(TestCase):
|
class HomePageTest(TestCase):
|
||||||
def test_bad_maths(self):
|
def test_home_page_returns_correct_html(self):
|
||||||
self.assertEqual(1 + 1, 3)
|
request = HttpRequest()
|
||||||
|
response = home_page(request)
|
||||||
|
html = response.content.decode("utf8")
|
||||||
|
self.assertIn("<title>To-Do lists</title>", html)
|
||||||
|
self.assertTrue(html.startswith("<html>"))
|
||||||
|
self.assertTrue(html.endswith("</html>"))
|
@ -1,3 +1,6 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from django.http import HttpResponse
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
def home_page(request):
|
||||||
|
return HttpResponse("<html><title>To-Do lists</title></html>")
|
Loading…
Reference in New Issue
Block a user