|
|
@@ -29,7 +29,7 @@ class NewVisitorTest(LiveServerTestCase):
|
|
|
raise e
|
|
|
time.sleep(0.5)
|
|
|
|
|
|
- def test_can_start_a_list_and_retrieve_it_later(self):
|
|
|
+ def test_can_start_a_list_for_one_user(self):
|
|
|
# Edith has heard about a cool new online to-do app. She goes
|
|
|
# to check out its homepage
|
|
|
self.browser.get(self.live_server_url)
|
|
|
@@ -65,3 +65,46 @@ class NewVisitorTest(LiveServerTestCase):
|
|
|
# enters "Armageddon"
|
|
|
# self.fail('Finish the test!')
|
|
|
# She is invited to enter a to-do item straight away
|
|
|
+
|
|
|
+ def test_multiple_users_can_start_lists_at_different_urls(self):
|
|
|
+ # Edith starts a new to-do list
|
|
|
+ self.browser.get(self.live_server_url)
|
|
|
+ inputbox = self.browser.find_element_by_id('input-new-movie')
|
|
|
+ inputbox.send_keys('Avatar')
|
|
|
+ inputbox.send_keys(Keys.ENTER)
|
|
|
+ self.wait_for_row_in_list_table('1: Avatar')
|
|
|
+
|
|
|
+ # She notices that her list has a unique URL
|
|
|
+ edith_list_url = self.browser.current_url
|
|
|
+ self.assertRegex(edith_list_url, '/libraries/.+')
|
|
|
+
|
|
|
+ ## We use a new browser session to make sure that no information
|
|
|
+ ## of Edith's is coming through from cookies etc
|
|
|
+ self.browser.quit()
|
|
|
+ self.browser = webdriver.Firefox()
|
|
|
+
|
|
|
+ # Francis visits the home page. There is no sign of Edith's
|
|
|
+ # list
|
|
|
+ self.browser.get(self.live_server_url)
|
|
|
+ page_text = self.browser.find_element_by_tag_name('body').text
|
|
|
+ self.assertNotIn('Avatar', page_text)
|
|
|
+ self.assertNotIn('make a fly', page_text)
|
|
|
+
|
|
|
+ # Francis starts a new list by entering a new item. He
|
|
|
+ # is less interesting than Edith...
|
|
|
+ inputbox = self.browser.find_element_by_id('input-new-movie')
|
|
|
+ inputbox.send_keys('X-Men')
|
|
|
+ inputbox.send_keys(Keys.ENTER)
|
|
|
+ self.wait_for_row_in_list_table('1: X-Men')
|
|
|
+
|
|
|
+ # Francis gets his own unique URL
|
|
|
+ francis_list_url = self.browser.current_url
|
|
|
+ self.assertRegex(francis_list_url, '/libraries/.+')
|
|
|
+ self.assertNotEqual(francis_list_url, edith_list_url)
|
|
|
+
|
|
|
+ # Again, there is no trace of Edith's list
|
|
|
+ page_text = self.browser.find_element_by_tag_name('body').text
|
|
|
+ self.assertNotIn('Avatar', page_text)
|
|
|
+ self.assertIn('X-Men', page_text)
|
|
|
+
|
|
|
+ # Satisfied, they both go back to sleep
|