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:
@@ -13,6 +13,7 @@ class NewVisitorTest(unittest.TestCase):
|
||||
|
||||
def test_can_start_a_todo_list(self):
|
||||
self.browser.get("http://localhost:8000")
|
||||
|
||||
self.assertIn("To-Do", self.browser.title)
|
||||
header_text = self.browser.find_element(By.TAG_NAME, 'h1').text
|
||||
self.assertIn('To-Do', header_text)
|
||||
@@ -27,12 +28,17 @@ class NewVisitorTest(unittest.TestCase):
|
||||
|
||||
table = self.browser.find_element(By.ID, 'id-list-table')
|
||||
rows = table.find_elements(By.TAG_NAME, 'tr')
|
||||
self.assertTrue(
|
||||
any(row.text == '1: Buy peacock feathers' for row in rows),
|
||||
'New to-do item did not appear in table',
|
||||
)
|
||||
self.assertIn('1: Buy peacock feathers', [row.text for row in rows])
|
||||
|
||||
self.fail("Finish the test!")
|
||||
inputbox = self.browser.find_element(By.ID, 'id-new-item')
|
||||
inputbox.send_keys('Use peacock feathers to make a fly')
|
||||
inputbox.send_keys(Keys.ENTER)
|
||||
time.sleep(1)
|
||||
|
||||
table = self.browser.find_element(By.ID, 'id-list-table')
|
||||
rows = table.find_elements(By.TAG_NAME, 'tr')
|
||||
self.assertIn('2: Use peacock feathers to make a fly', [row.text for row in rows])
|
||||
self.assertIn('1: Buy peacock feathers', [row.text for row in rows])
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user