Fakultas Ilmu Komputer UI

Commit 2d2801dc authored by Rayza Arasj Mahardhika's avatar Rayza Arasj Mahardhika
Browse files

add unit test for about page

parent 26a7f504
......@@ -2,7 +2,7 @@ from django.urls import resolve
from django.test import TestCase
from django.http import HttpRequest
from lists.views import home_page
from lists.views import home_page, about_page
class HomePageTest(TestCase):
......@@ -18,3 +18,17 @@ class HomePageTest(TestCase):
self.assertIn('<title>Rayza\'s Homepage</title>', html)
self.assertIn('<h1>Welcome to Rayza\'s Homepage</h1>', html)
self.assertTrue(html.endswith('</html>'))
def test_about_url_resolves_to_about_page_view(self):
found = resolve('/about')
self.assertEqual(found.func, about_page)
def test_about_page_returns_correct_html(self):
request = HttpRequest()
response = home_page(request)
html = response.content.decode('utf8')
self.assertTrue(html.startswith('<html>'))
self.assertIn('<title>Rayza\'s About Page</title>', html)
self.assertIn('<h1>Hello my name is Rayza Arasj Mahardhika</h1>', html)
self.asserIn('<p>I\'m 21 years old</p>')
self.assertTrue(html.endswith('</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