Skip to content

Commit 542b876

Browse files
authored
Merge pull request #119 from bhagerty/chapter-7
Chapter 7 - small revision for accuracy
2 parents e714d15 + 75150ff commit 542b876

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

chapter_post_and_database.asciidoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,15 +1545,17 @@ worse:
15451545

15461546
Grrr. We're so close! We're going to need some kind of automated way of
15471547
tidying up after ourselves. For now, if you feel like it, you can do it
1548-
manually, by deleting the database and re-creating it fresh with `migrate`:
1548+
manually, by deleting the database and re-creating it fresh with `migrate`
1549+
(you'll need to shut down your Django server first):
15491550

15501551
[subs="specialcharacters,quotes"]
15511552
----
15521553
$ *rm db.sqlite3*
15531554
$ *python manage.py migrate --noinput*
15541555
----
15551556

1556-
And then reassure yourself that the FT still passes.
1557+
And then (after restarting your server!) reassure yourself that the FT still
1558+
passes.
15571559

15581560
Apart from that little bug in our functional testing, we've got some code
15591561
that's more or less working. Let's do a commit.((("", startref="DTproduction05")))

chapter_unit_test_first_view.asciidoc

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,11 @@ NOTE: If you've never come across regular expressions, you can get away with
488488
just taking my word for it, for now--but you should make a mental note to
489489
go learn about them.
490490

491-
We'll also get rid of the admin URL, because we won't be using the Django
492-
admin site for now:
491+
We'll make a couple of changes to what we import and to what we test. First,
492+
we don't need to import the `admin` module from `django.contrib`, but we do
493+
need to import the `views` module from `lists`. Second, we'll rewrite the
494+
URL pattern to use the empty-string expression instead of the `admin` URL,
495+
since we won't be using the Django admin site for now:
493496

494497

495498
[role="sourcecode dofirst-ch03l003"]
@@ -597,7 +600,7 @@ with HTML to the browser. Open up 'lists/tests.py', and add a new
597600
----
598601
from django.urls import resolve
599602
from django.test import TestCase
600-
from django.http import HttpRequest
603+
from django.http import HttpRequest #<1>
601604
602605
from lists.views import home_page
603606
@@ -621,12 +624,13 @@ class HomePageTest(TestCase):
621624

622625
What's going on in this new test?
623626

624-
<1> We create an `HttpRequest` object, which is what Django will see when
625-
a user's browser asks for a page.
627+
<1> We import the `HttpRequest` class so that we can then create an
628+
`HttpRequest` object within our test. When a user's browser asks for a
629+
page, Django will see that object.
626630

627-
<2> We pass it to our `home_page` view, which gives us a response. You won't be
628-
surprised to hear that this object is an instance of a class called
629-
`HttpResponse`.
631+
<2> We pass the `HttpRequest` object to our `home_page` view, which gives us a
632+
response. You won't be surprised to hear that the response is an instance
633+
of a class called `HttpResponse`.
630634

631635
<3> Then, we extract the `.content` of the response. These are the raw bytes,
632636
the ones and zeros that would be sent down the wire to the user's browser.

chapter_working_incrementally.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ class ListViewTest(TestCase):
717717
====
718718

719719

720-
`assertTemplateUsed` is one of the more useful functions that the Django Test
720+
`assertTemplateUsed` is one of the more useful methods that the Django Test
721721
Client gives us. Let's see what it says:
722722

723723
----

0 commit comments

Comments
 (0)