diff --git a/functional_tests.py b/functional_tests.py
index 80415eb3bbb5d076b998ec61bae5fa0ebf28b887..f3702400be8f04d11874fe7f7ce96992eedcf8bf 100644
--- a/functional_tests.py
+++ b/functional_tests.py
@@ -1,4 +1,5 @@
from selenium import webdriver
+from selenium.webdriver.common.keys import Keys
import unittest
@@ -8,15 +9,45 @@ class NewVisitorTest(unittest.TestCase):
self.browser.implicitly_wait(3)
def tearDown(self):
- self.browser.close()
+ self.browser.quit()
def test_can_start_a_list_and_retrieve_it_later(self):
self.browser.get('http://localhost:8000')
- self.assertIn('Rumah', self.browser.title)
- h = self.browser.page_source
- self.assertIn('Jordan Muhammad Andrianda', h)
- self.assertIn('1506722765', h)
+ # She notices the page title and header mention to-do lists
+ self.assertIn('To-Do', self.browser.title)
+ header_text = self.browser.find_element_by_tag_name('h1').text
+ self.assertIn('To-Do', header_text)
+
+ # She is invited to enter a to-do item straight away
+ inputbox = self.browser.find_element_by_id('id_new_item')
+ self.assertEqual(
+ inputbox.get_attribute('placeholder'),
+ 'Enter a to-do item'
+ )
+ # She types "Buy peacock feathers" into a text box (Edith's hobby
+ # is tying fly-fishing lures)
+ inputbox.send_keys('Buy peacock feathers')
+
+ # When she hits enter, the page updates, and now the page lists
+ # "1: Buy peacock feathers" as an item in a to-do list table
+ inputbox.send_keys(Keys.ENTER)
+
+ 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"
+ )
+ # There is still a text box inviting her to add another item. She
+ # enters "Use peacock feathers to make a fly" (Edith is very
+ # methodical)
+ self.fail('Finish the test!')
+
+ #h = self.browser.page_source
+ #self.assertIn('Jordan Muhammad Andrianda', h)
+ #self.assertIn('1506722765', h)
diff --git a/lists/templates/home.html b/lists/templates/home.html
new file mode 100644
index 0000000000000000000000000000000000000000..5474b018681f18bf147d180d35b6a439c58a84ea
--- /dev/null
+++ b/lists/templates/home.html
@@ -0,0 +1,10 @@
+
+
+ To-Do lists
+
+
+
Your To-Do list
+
+
+
+
diff --git a/lists/tests.py b/lists/tests.py
index 4a7e493da495ae6ae046c25b338fd5b24674662a..b02f54c9934326334b518e5e35d70ed9c2052797 100644
--- a/lists/tests.py
+++ b/lists/tests.py
@@ -2,6 +2,7 @@ from django.test import TestCase
from django.urls import resolve
from django.http import HttpRequest
from lists.views import home_page
+from django.template.loader import render_to_string
# Create your tests here.
class HomePageTest(TestCase):
@@ -12,11 +13,20 @@ class HomePageTest(TestCase):
def test_home_page_returns_correct_html(self):
request = HttpRequest() #
response = home_page(request) #
- self.assertTrue(response.content.startswith(b'')) #
- self.assertIn(b'Rumah', response.content) #
- self.assertIn(b'