Last active
April 26, 2020 10:33
-
-
Save LouisdeBruijn/86f29f9a932080d8cf5f34684bfda8d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.urls import resolve | |
| from django.test import TestCase | |
| from projectname.views import home_page | |
| class HomePageTest(TestCase): | |
| """Unittesting class for our Django project.""" | |
| def test_root_url_resolves_to_home_page_view(self): | |
| """Test the home page url.""" | |
| found = resolve('/') | |
| self.assertEqual(found.func, home_page) | |
| def test_home_page_returns_correct_html(self): | |
| """Test home_page template.""" | |
| response = self.client.get('/') | |
| html = response.content.decode('utf8') | |
| self.assertTrue(html.strip().startswith('<!DOCTYPE HTML>')) | |
| self.assertIn('<html>', html) | |
| self.assertIn('<title>Everything Python</title>', html) | |
| self.assertTrue(html.strip().endswith('</html>')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment