NewVisitorTest() in functional_tests almost passes, but needs DRY refactor; pair of functions added to HomePageTest() in apps.dashboard.tests; home_page() FBV in .views streamlined using django templating; templating also applied & form w. csrf functionality added to to-do list in home.html

This commit is contained in:
Disco DeDisco
2025-12-30 23:47:25 -05:00
parent 1ddabe4448
commit f6b73a17ea
4 changed files with 30 additions and 10 deletions

View File

@@ -5,6 +5,12 @@ class HomePageTest(TestCase):
response = self.client.get('/')
self.assertTemplateUsed(response, 'apps/dashboard/home.html')
def test_renders_homepage_content(self):
def test_renders_input_form(self):
response = self.client.get('/')
self.assertContains(response, 'To-Do')
self.assertContains(response, '<form method="POST">')
self.assertContains(response, '<input name="item-text"')
def test_can_save_a_POST_request(self):
response = self.client.post('/', data={'item-text': 'A new dashboard item'})
self.assertContains(response, 'A new dashboard item')
self.assertTemplateUsed(response, 'apps/dashboard/home.html')