Skip to content

Commit 61781b8

Browse files
committed
Harry tweaks in 15
1 parent e55c8e2 commit 61781b8

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

chapter_15_advanced_forms.asciidoc

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
[[chapter_15_advanced_forms]]
22
== More Advanced Forms
33

4-
// TODO Harry write a paragraph about the server side validation
5-
64

75
Now let's look at some more advanced forms usage. We've helped our users
86
to avoid blank list items, so now let's help them avoid duplicate items.
97

10-
This chapter goes into more intricate details of Django's form validation, and
11-
you have my official permission to skip it if you already know all about
12-
customising Django forms, or if you're reading this book for the TDD rather
13-
than for the Django.
8+
Our validation constraint so far has been about preventing blank items,
9+
and as you may remember, it turned out we can enforce that very easily in the frontend.
10+
Avoiding duplicate items is less straightforward to do in the frontend,
11+
(although not impossible of course),
12+
so this chapter will lean more heavily on server-side validation,
13+
and bubbling errors from the backend back up to the UI.
14+
15+
This chapter goes into more intricate details of Django's forms framework,
16+
so you have my official permission to skip it
17+
if you already know all about customising Django forms and how to display errors in the UI,
18+
or if you're reading this book for the TDD rather than for the Django.
1419

15-
If you're still learning Django, there's good stuff in here. If you
16-
want to skip ahead, that's OK too. Make sure you take a quick look at the aside
17-
on developer stupidity, and the recap on testing views at the end.
20+
If you're still learning Django, there's good stuff in here!
21+
If you want to skip ahead, that's OK too.
22+
Make sure you take a quick look at the
23+
<<testing-for-stupidity,aside on developer stupidity>>,
24+
and the <<what-to-test-in-views,recap on testing views>> at the end.
1825

1926

2027
=== Another FT for Duplicate Items
@@ -25,7 +32,9 @@ on developer stupidity, and the recap on testing views at the end.
2532
((("functional tests (FTs)", "for duplicate items", secondary-sortas="duplicate items", id="FTduplicate15")))
2633
((("duplicate items testing", "functional test for", id="DITfunctional15")))
2734
((("user interactions", "preventing duplicate items", id="UIduplicate15")))
28-
We add a second test method to `ItemValidationTest`:
35+
We add a second test method to `ItemValidationTest`,
36+
and tell a little story about what we want to see happen
37+
when a user tries to enter the same item twice into their to-do list:
2938

3039
[role="sourcecode"]
3140
.src/functional_tests/test_list_item_validation.py (ch15l001)
@@ -53,11 +62,13 @@ def test_cannot_add_duplicate_items(self):
5362
----
5463
====
5564

56-
Why have two test methods rather than extending one, or having a new file
57-
and class? It's a judgement call. These two feel closely related; they're
58-
both about validation on the same input field, so it feels right to
59-
keep them in the same file. On the other hand, they're logically separate
60-
enough that it's practical to keep them in different methods:
65+
Why have two test methods rather than extending one,
66+
or having a new file and class?
67+
It's a judgement call. These two feel closely related;
68+
they're both about validation on the same input field,
69+
so it feels right to keep them in the same file.
70+
On the other hand, they're logically separate enough
71+
that it's practical to keep them in different methods:
6172

6273

6374
[subs="specialcharacters,macros"]
@@ -907,6 +918,7 @@ a recap of the biggest (and highest-level) one, 'test_views' (the listing
907918
shows just the key tests and assertions, and your order may vary):
908919
// CSANAD: Why are we only showing ListViewTest? HomePageTest, NewListTest
909920
921+
[[what-to-test-in-views]]
910922
.What to Test in Views
911923
******************************************************************************
912924

0 commit comments

Comments
 (0)