Chapter 26. The Token Social Bit, the Page Pattern, and an Exercise for the Reader
Are jokes about how “everything has to be social now” slightly old hat? Yes, Harry; they were old hat 10 years ago when you started writing this book, and they’re positively prehistoric now. Irregardless, let’s say lists are often better shared. We should allow our users to collaborate on their lists with other users.
Along the way, we’ll improve our FTs by starting to implement something called the “page object pattern”. Then, rather than showing you explicitly what to do, I’m going to let you write your unit tests and application code by yourself. Don’t worry; you won’t be totally on your own! I’ll give an outline of the steps to take, as well as some hints and tips.
But still—if you haven’t already, this is the chapter where you get a chance to spread your wings. Enjoy!
An FT with Multiple Users, and addCleanup
Let’s get started—we’ll need two users for this FT:
src/functional_tests/test_sharing.py (ch26l001)
fromseleniumimportwebdriverfromselenium.webdriver.common.byimportByfrom.baseimportFunctionalTestdefquit_if_possible(browser):try:browser.quit()except:passclassSharingTest(FunctionalTest):deftest_can_share_a_list_with_another_user(self):# Edith is a logged-in userself.create_pre_authenticated_session("edith@example.com")edith_browser=self.browserself.addCleanup(lambda:quit_if_possible(edith_browser))# Her friend Onesiphorus is also hanging out on the lists ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access