Skip to content

Commit f3902e6

Browse files
committed
more listing/tests progress
1 parent 096d08d commit f3902e6

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

chapter_22_outside_in.asciidoc

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ write our FT to look for a "My Lists" page:
8989
====
9090
[source,python]
9191
----
92+
from selenium.webdriver.common.by import By
93+
[...]
94+
9295
def test_logged_in_users_lists_are_saved_as_my_lists(self):
9396
# Edith is a logged-in user
9497
self.create_pre_authenticated_session("[email protected]")
@@ -100,14 +103,14 @@ write our FT to look for a "My Lists" page:
100103
first_list_url = self.browser.current_url
101104
102105
# She notices a "My lists" link, for the first time.
103-
self.browser.find_element_by_link_text("My lists").click()
106+
self.browser.find_element(By.LINK_TEXT, "My lists").click()
104107
105108
# She sees that her list is in there, named according to its
106109
# first list item
107110
self.wait_for(
108-
lambda: self.browser.find_element_by_link_text("Reticulate splines")
111+
lambda: self.browser.find_element(By.LINK_TEXT, "Reticulate splines")
109112
)
110-
self.browser.find_element_by_link_text("Reticulate splines").click()
113+
self.browser.find_element(By.LINK_TEXT, "Reticulate splines").click()
111114
self.wait_for(
112115
lambda: self.assertEqual(self.browser.current_url, first_list_url)
113116
)
@@ -142,21 +145,21 @@ we check that only logged-in users can see the "My Lists" page:
142145
second_list_url = self.browser.current_url
143146
144147
# Under "my lists", her new list appears
145-
self.browser.find_element_by_link_text("My lists").click()
146-
self.wait_for(
147-
lambda: self.browser.find_element_by_link_text("Click cows")
148-
)
149-
self.browser.find_element_by_link_text("Click cows").click()
148+
self.browser.find_element(By.LINK_TEXT, "My lists").click()
149+
self.wait_for(lambda: self.browser.find_element(By.LINK_TEXT, "Click cows"))
150+
self.browser.find_element(By.LINK_TEXT, "Click cows").click()
150151
self.wait_for(
151152
lambda: self.assertEqual(self.browser.current_url, second_list_url)
152153
)
153154
154155
# She logs out. The "My lists" option disappears
155-
self.browser.find_element_by_link_text("Log out").click()
156-
self.wait_for(lambda: self.assertEqual(
157-
self.browser.find_elements_by_link_text("My lists"),
158-
[],
159-
))
156+
self.browser.find_element(By.LINK_TEXT, "Log out").click()
157+
self.wait_for(
158+
lambda: self.assertEqual(
159+
self.browser.find_elements(By.LINK_TEXT, "My lists"),
160+
[],
161+
)
162+
)
160163
----
161164
====
162165

@@ -204,7 +207,7 @@ The first error should look like this:
204207

205208
[subs="specialcharacters,macros"]
206209
----
207-
$ pass:quotes[*python3 manage.py test functional_tests.test_my_lists*]
210+
$ pass:quotes[*python3 src/manage.py test functional_tests.test_my_lists*]
208211
[...]
209212
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate
210213
element: My lists
@@ -243,7 +246,7 @@ the next failure:
243246

244247
[subs="specialcharacters,macros"]
245248
----
246-
$ pass:quotes[*python3 manage.py test functional_tests.test_my_lists*]
249+
$ pass:quotes[*python3 src/manage.py test functional_tests.test_my_lists*]
247250
[...]
248251
lambda: self.browser.find_element_by_link_text('Reticulate splines')
249252
[...]
@@ -358,7 +361,7 @@ them to be clickable links named after the first item:
358361

359362
[subs="specialcharacters,macros"]
360363
----
361-
$ pass:quotes[*python3 manage.py test functional_tests.test_my_lists*]
364+
$ pass:quotes[*python3 src/manage.py test functional_tests.test_my_lists*]
362365
[...]
363366
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate
364367
element: Reticulate splines
@@ -499,7 +502,7 @@ we've got any further:
499502

500503
[subs="specialcharacters,macros"]
501504
----
502-
$ pass:quotes[*python manage.py test functional_tests*]
505+
$ pass:quotes[*python src/manage.py test functional_tests*]
503506
[...]
504507
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate
505508
element: Reticulate splines
@@ -802,7 +805,7 @@ Because we need to make some migrations:
802805

803806
[subs="specialcharacters,macros"]
804807
----
805-
$ pass:quotes[*python manage.py makemigrations*]
808+
$ pass:quotes[*python src/manage.py makemigrations*]
806809
Migrations for 'lists':
807810
lists/migrations/0006_list_owner.py
808811
- Add field owner to list
@@ -856,7 +859,7 @@ And that gets us passing!
856859

857860
[subs="specialcharacters,macros"]
858861
----
859-
$ pass:quotes[*python manage.py test lists*]
862+
$ pass:quotes[*python src/manage.py test lists*]
860863
[...]
861864
.......................................
862865
---------------------------------------------------------------------
@@ -912,7 +915,7 @@ and a working "My Lists" page (<<my-lists-page>>)!
912915

913916
[subs="specialcharacters,macros"]
914917
----
915-
$ pass:quotes[*python manage.py test functional_tests*]
918+
$ pass:quotes[*python src/manage.py test functional_tests*]
916919
[...]
917920
Ran 8 tests in 93.819s
918921

tests/update_source_repo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from chapters import CHAPTERS
77

8-
REMOTE = "local" if getpass.getuser() == "harry" else "origin"
8+
REMOTE = "local" if "harry" in getpass.getuser() else "origin"
99
BASE_FOLDER = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1010

1111

0 commit comments

Comments
 (0)