20 lines
680 B
Python
20 lines
680 B
Python
from django.urls import resolve
|
|
from django.test import TestCase
|
|
from django.http import HttpRequest
|
|
from palindromes.views import caculate_palindromes
|
|
|
|
|
|
class HomePageTest(TestCase):
|
|
|
|
def test_root_url_resolves_to_calculate_palindrome_view(self):
|
|
found = resolve('/')
|
|
self.assertEqual(found.func, caculate_palindromes)
|
|
|
|
def test_home_page_returns_correct_html(self):
|
|
request = HttpRequest()
|
|
response = caculate_palindromes(request)
|
|
html = response.content.decode('utf8')
|
|
self.assertTrue(html.startswith('<html>'))
|
|
self.assertIn('<title>Palindromes!</title>', html)
|
|
self.assertTrue(html.endswith('</html>'))
|