Skip to content

Commit 0f941bd

Browse files
committed
small listing fixes in 9
1 parent a7b7a2a commit 0f941bd

File tree

4 files changed

+29
-44
lines changed

4 files changed

+29
-44
lines changed

chapter_09_docker.asciidoc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,20 +333,19 @@ called `TEST_SERVER`:
333333

334334

335335
[role="sourcecode"]
336-
.functional_tests/tests.py (ch08l001)
336+
.functional_tests/tests.py (ch09l001)
337337
====
338338
[source,python]
339339
----
340340
import os
341341
[...]
342342
343343
class NewVisitorTest(StaticLiveServerTestCase):
344-
345344
def setUp(self):
346345
self.browser = webdriver.Firefox()
347-
test_server = os.environ.get('TEST_SERVER') #<1>
346+
test_server = os.environ.get("TEST_SERVER") #<1>
348347
if test_server:
349-
self.live_server_url = 'http://' + test_server #<2>
348+
self.live_server_url = "http://" + test_server #<2>
350349
----
351350
====
352351

@@ -408,14 +407,13 @@ ERROR: test_can_start_a_todo_list
408407
(functional_tests.tests.NewVisitorTest.test_can_start_a_todo_list)
409408
---------------------------------------------------------------------
410409
Traceback (most recent call last):
411-
File "...goat-book/functional_tests/tests.py", line 31, in
410+
File "...goat-book/functional_tests/tests.py", line 38, in
412411
test_can_start_a_todo_list
413412
self.browser.get(self.live_server_url)
414413
[...]
414+
415415
selenium.common.exceptions.WebDriverException: Message: Reached error page: abo
416-
ut:neterror?e=connectionFailure&u=http%3A//localhost:8888/&c=UTF-8&
417-
f=regular&d=Firefox%20can%27t%20establish%20a%20connection%20to%20the%20server%
418-
20at%20localhost.
416+
ut:neterror?e=connectionFailure&u=http%3A//localhost:8888/[...]
419417
420418
421419
Ran 1 tests in 5.518s
@@ -1306,6 +1304,9 @@ CMD python manage.py runserver
13061304
----
13071305
====
13081306
1307+
1308+
1309+
13091310
Let's start by re-creating the database with `migrate`
13101311
(when we moved everything into `./src`, we left the database file behind):
13111312

source/chapter_09_docker/superlists

Submodule superlists updated 1 file

tests/book_tester.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@
2828
)
2929

3030

31-
DO_SERVER_COMMANDS = True
32-
if getuser() == "jenkins":
33-
DO_SERVER_COMMANDS = False
34-
if "NO_SERVER_COMMANDS" in os.environ:
35-
DO_SERVER_COMMANDS = False
31+
# DO_SERVER_COMMANDS = True
32+
# if os.environ.get("CI") or os.environ.get("NO_SERVER_COMMANDS"):
33+
DO_SERVER_COMMANDS = False
3634

3735

3836
def contains(inseq, subseq):

tests/test_chapter_09_docker.py

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,24 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
import unittest
43
import subprocess
54

65
from book_tester import ChapterTest, DO_SERVER_COMMANDS
76

87

98
class Chapter9Test(ChapterTest):
10-
chapter_name = 'chapter_09_docker'
11-
previous_chapter = 'chapter_08_prettification'
9+
chapter_name = "chapter_09_docker"
10+
previous_chapter = "chapter_08_prettification"
1211

1312
def test_listings_and_commands_and_output(self):
1413
self.parse_listings()
1514

1615
# sanity checks
17-
self.assertEqual(self.listings[0].type, 'code listing with git ref')
18-
self.assertEqual(self.listings[1].type, 'test')
16+
self.assertEqual(self.listings[0].type, "code listing with git ref")
17+
self.assertEqual(self.listings[1].type, "test")
1918

2019
self.start_with_checkout()
2120

22-
# skips
23-
self.skip_with_check(13, 'replace the URL in the next line with')
24-
self.skip_with_check(24, 'do some git config first')
25-
self.skip_with_check(33, 'Performing system checks')
26-
self.skip_with_check(44, 'Starting development server')
27-
28-
if not DO_SERVER_COMMANDS:
29-
self.skip_with_check(38, 'curl staging.ottg.co.uk')
30-
self.skip_with_check(39, 'Failed to connect to staging.ottg.co.uk')
31-
self.skip_with_check(47, 'curl staging.ottg.co.uk:8000')
32-
self.skip_with_check(48, '<!DOCTYPE html>')
33-
34-
vm_restore = None # 'MANUAL_1'
21+
vm_restore = None # 'MANUAL_1'
3522

3623
# hack fast-forward
3724
skip = False
@@ -41,18 +28,18 @@ def test_listings_and_commands_and_output(self):
4128
# self.sourcetree.get_commit_spec('ch08l001')
4229
# ))
4330
self.pos = 43
44-
self.current_server_cd = '~/sites/$SITENAME'
45-
self.sourcetree.run_command('git checkout {0}'.format(
46-
self.sourcetree.get_commit_spec('ch08l004')
47-
))
48-
vm_restore = 'MANUAL_2'
31+
self.current_server_cd = "~/sites/$SITENAME"
32+
self.sourcetree.run_command(
33+
"git checkout {0}".format(self.sourcetree.get_commit_spec("ch08l004"))
34+
)
35+
vm_restore = "MANUAL_2"
4936

5037
if DO_SERVER_COMMANDS:
5138
if vm_restore:
52-
subprocess.check_call(['vagrant', 'snapshot', 'restore', vm_restore])
39+
subprocess.check_call(["vagrant", "snapshot", "restore", vm_restore])
5340
else:
54-
subprocess.check_call(['vagrant', 'destroy', '-f'])
55-
subprocess.check_call(['vagrant', 'up'])
41+
subprocess.check_call(["vagrant", "destroy", "-f"])
42+
subprocess.check_call(["vagrant", "up"])
5643

5744
while self.pos < len(self.listings):
5845
listing = self.listings[self.pos]
@@ -62,10 +49,9 @@ def test_listings_and_commands_and_output(self):
6249
self.assert_all_listings_checked(self.listings)
6350
self.check_final_diff()
6451
if DO_SERVER_COMMANDS:
65-
subprocess.run(['vagrant', 'snapshot', 'delete', 'MANUAL_END'])
66-
subprocess.run(['vagrant', 'snapshot', 'save', 'MANUAL_END'], check=True)
67-
52+
subprocess.run(["vagrant", "snapshot", "delete", "MANUAL_END"])
53+
subprocess.run(["vagrant", "snapshot", "save", "MANUAL_END"], check=True)
6854

6955

70-
if __name__ == '__main__':
56+
if __name__ == "__main__":
7157
unittest.main()

0 commit comments

Comments
 (0)