Beispiel #1
0
    def test_aesthetics(self):
        # Emily goes to the home page
        self.browser.get(self.live_server_url)
        self.browser.set_window_size(1024, 768)

        list_page = ListPage(self)

        # She notices the input box is nicely centered
        input_box = list_page.get_item_input_box()

        self.assertAlmostEqual(input_box.location['x'] +
                               input_box.size['width'] / 2,
                               512,
                               delta=20)

        # She starts a new list and sees the input is nicely centered there too
        new_text = 'random item'

        list_page.add_list_item(new_text)

        input_box = list_page.get_item_input_box()

        self.assertAlmostEqual(input_box.location['x'] +
                               input_box.size['width'] / 2,
                               512,
                               delta=20)
Beispiel #2
0
    def test_can_share_a_list_with_another_user(self):
        # Emily is a logged in user
        self.create_pre_authenticated_session(TEST_EMAIL_1)

        emily_browser = self.browser

        self.addCleanup(lambda: quit_if_possible(emily_browser))

        # Her friend Oniciferous is also hanging out on the lists site
        oni_browser = get_webdriver()

        self.addCleanup(lambda: quit_if_possible(oni_browser))

        self.browser = oni_browser

        self.create_pre_authenticated_session(TEST_EMAIL_2)

        # Emily goes to the home page and starts a list
        self.browser = emily_browser

        self.browser.get(self.live_server_url)

        list_page = ListPage(self).add_list_item('Get help')

        # She notices a "Share this list" option
        share_box = list_page.get_share_box()

        self.assertEqual(share_box.get_attribute('placeholder'),
                         '*****@*****.**')

        # She shares her list. The page updates to say that it's shared with Oniciferous
        list_page.share_list_with(TEST_EMAIL_2)

        # Oniciferous now goes to the lists page with his browser
        self.browser = oni_browser

        MyListsPage(self).go_to_my_lists_page()

        # He sees Edith's list in there!
        self.browser.find_element_by_link_text('Get help').click()

        # On the list page, Oniciferous can see it says that it's Edit's list
        self.wait_for(
            lambda: self.assertEqual(list_page.get_list_owner(), TEST_EMAIL_1))

        # He adds an item to the list
        list_page.add_list_item(TEST_ITEM)

        # When Edith refreshes the page, she sees Oniciferou's addition
        self.browser = emily_browser

        self.browser.refresh()

        list_page.wait_for_row_in_list_table(TEST_ITEM, 2)
    def test_multiple_users_can_start_lists_at_different_urls(self):
        # Emily starts a new to-do list
        self.browser.get(self.live_server_url)

        list_page = ListPage(self).add_list_item(E_ITEM_1)
    
        # She notices that her list has a unique URL.
        emily_list_url = self.browser.current_url
        self.assertRegex(emily_list_url, '/lists/.+')

        # Now a new user, Felipe, comes along to the site.
    
        # # We use a new browser session to make sure that no information of Emily's is coming through from cookies,
        self.browser.refresh()
        self.browser.quit()
    
        self.browser = get_webdriver()
    
        # Felipe visits the home page. There is no sign of Emily's list
        self.browser.get(self.live_server_url)
    
        page_text = self.browser.find_element_by_tag_name('body').text
    
        self.assertNotIn(E_ITEM_1, page_text)
        self.assertNotIn(E_ITEM_2, page_text)
    
        # Felipe starts a new list by entering a new item. He is into techy stuff...
        list_page.add_list_item(F_ITEM_1)
    
        # Felipe gets his own unique URL
        felipe_list_url = self.browser.current_url
        self.assertRegex(felipe_list_url, '/lists/.+')
        self.assertNotEqual(felipe_list_url, emily_list_url)
    
        # Again, there is no trace of Emily's list
        page_text = self.browser.find_element_by_tag_name('body').text
    
        self.assertNotIn(E_ITEM_1, page_text)
        self.assertNotIn(E_ITEM_2, page_text)