Skip to content

Commit 68f3c1c

Browse files
committed
more fixes in tests for 9
1 parent 80ae169 commit 68f3c1c

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

chapter_09_docker.asciidoc

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,13 +1341,9 @@ NOTE: If you don't see this error,
13411341

13421342
==== Should we run "migrate" inside the Dockerfile? No.
13431343

1344-
// JAN: Not sure I understand this line.
1345-
// You're saying that we shouldn't run migrate inside our Dockerfile,
1346-
// but then in the next line you do exactly that
1347-
13481344
So, should we include `manage.py migrate` in our Dockerfile?
13491345

1350-
If you try it, you'll find it certainly fixes the problem:
1346+
If you try it, you'll find it certainly _seems_ to fix the problem:
13511347

13521348
[role="sourcecode"]
13531349
.Dockerfile (ch09l008)
@@ -1365,17 +1361,23 @@ CMD python manage.py runserver 0.0.0.0:8888
13651361
<1> We run `migrate` using the `--noinput` argument to suppress any little "are you sure" prompts.
13661362

13671363

1368-
If we rebuild the image and try our FTs again, they all pass!
1364+
If we rebuild the image...
1365+
1366+
[subs="specialcharacters,quotes"]
1367+
----
1368+
$ *docker build -t superlists . && docker run -p 8888:8888 -it superlists*
1369+
[...]
1370+
Starting development server at http://0.0.0.0:8888/
1371+
----
13691372

1373+
...and try our FTs again, they all pass!
13701374

1371-
[role="small-code"]
1375+
[role="small-code pause-first"]
13721376
[subs="specialcharacters,macros"]
13731377
----
13741378
$ pass:quotes[*TEST_SERVER=localhost:8888 ./src/manage.py test src/functional_tests \
13751379
--failfast*]
1376-
Found 3 test(s).
1377-
Creating test database for alias 'default'...
1378-
System check identified no issues (0 silenced).
1380+
[...]
13791381
...
13801382
---------------------------------------------------------------------
13811383
Ran 3 tests in 26.965s
@@ -1388,20 +1390,17 @@ which is not what we want,
13881390
because the system image is mean to be something fixed and stateless,
13891391
whereas the database is living, stateful data that should change over time.
13901392

1393+
// DAVID: This is an important point which might need a bit more explanation.
1394+
// What would happen if we did?
13911395

13921396
=== Mounting files inside the container.
13931397

13941398
We want the database on the server to have totally separate data from the one on our machine.
1395-
// CSANAD: we need to list `src/db.sqlite3` in the .dockerignore file to achieve this.
1396-
// Otherwise, if the reader did not delete the DB, it would still end up built into
1397-
// the image since the COPY directive copies everything that's inside `src`.
1398-
1399-
// DAVID: This is an important point which might need a bit more explanation.
1400-
// What would happen if we did?
14011399

14021400
In most deployments, you'd probably be talking to a separate database server, like postgres.
14031401

1404-
For the purposes of this book, the easiest analogy to a server that's "outside" our container,
1402+
For the purposes of this book,
1403+
the easiest analogy to a server that's "outside" our container,
14051404
is to access the database from the filesystem outside the container.
14061405

14071406
That also gives us a convenient excuse to talk about mounting files in Docker,
@@ -1478,9 +1477,7 @@ And we check the FTs again.
14781477
----
14791478
$ pass:quotes[*TEST_SERVER=localhost:8888 ./src/manage.py test src/functional_tests \
14801479
--failfast*]
1481-
Found 3 test(s).
1482-
Creating test database for alias 'default'...
1483-
System check identified no issues (0 silenced).
1480+
[...]
14841481
...
14851482
---------------------------------------------------------------------
14861483
Ran 3 tests in 26.965s

tests/sourcetree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def run_command(
136136
if user_input and not user_input.endswith("\n"):
137137
user_input += "\n"
138138
if user_input:
139-
print("sending user input: {}".format(user_input))
139+
print(f"sending user input: {user_input}")
140140
output, _ = process.communicate(user_input)
141141
if process.returncode and not ignore_errors:
142142
if (

tests/test_chapter_09_docker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ def test_listings_and_commands_and_output(self):
3030

3131
# hack fast-forward
3232
if os.environ.get("SKIP"):
33-
self.pos = 8
33+
# self.pos = 8
3434
# self.pos = 18
35+
self.pos = 60
3536
self.sourcetree.run_command(
36-
"git checkout {}".format(self.sourcetree.get_commit_spec("ch09l001"))
37+
# "git checkout {}".format(self.sourcetree.get_commit_spec("ch09l001"))
3738
# "git checkout {}".format(self.sourcetree.get_commit_spec("ch09l003"))
39+
"git checkout {}".format(self.sourcetree.get_commit_spec("ch09l008"))
3840
)
41+
print(f"Running in: {self.sourcetree.tempdir}")
3942
# vm_restore = "MANUAL_2"
4043

4144
if DO_SERVER_COMMANDS:

0 commit comments

Comments
 (0)