Skip to content

Commit 556d3e2

Browse files
committed
update What to Test in Views
1 parent d18f82a commit 556d3e2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

chapter_15_advanced_forms.asciidoc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,8 @@ real app.
886886
887887
We have one unit test file for each of our key source code files. Here's
888888
a recap of the biggest (and highest-level) one, 'test_views' (the listing
889-
shows just the key tests and assertions):
889+
shows just the key tests and assertions, and your order may vary):
890+
// CSANAD: Why are we only showing ListViewTest? HomePageTest, NewListTest
890891
891892
.What to Test in Views
892893
******************************************************************************
@@ -898,7 +899,7 @@ shows just the key tests and assertions):
898899
----
899900
class ListViewTest(TestCase):
900901
def test_uses_list_template(self):
901-
response = self.client.get(f'/lists/{list_.id}/') #<1>
902+
response = self.client.get(f'/lists/{mylist.id}/') #<1>
902903
self.assertTemplateUsed(response, 'list.html') #<2>
903904
def test_passes_correct_list_to_template(self):
904905
self.assertEqual(response.context['list'], correct_list) #<3>
@@ -924,7 +925,7 @@ class ListViewTest(TestCase):
924925
def test_for_invalid_input_shows_error_on_page(self):
925926
self.assertContains(response, escape(EMPTY_ITEM_ERROR)) #<7>
926927
def test_duplicate_item_validation_errors_end_up_on_lists_page(self):
927-
self.assertContains(response, expected_error)
928+
self.assertContains(response, expected_error) #<7>
928929
self.assertTemplateUsed(response, 'list.html')
929930
self.assertEqual(Item.objects.all().count(), 1)
930931
----
@@ -933,10 +934,10 @@ class ListViewTest(TestCase):
933934
934935
<1> Use the Django Test Client.
935936
936-
<2> Check the template used. Then, check each item in the template context.
937+
<2> Check the template used.
938+
// CSANAD: we aren't asserting anything else in this test
937939
938-
<3> Check that any objects are the right ones, or querysets have the
939-
correct items.
940+
<3> Check that received objects are the right ones.
940941
941942
<4> Check that any forms are of the correct class.
942943
@@ -953,6 +954,8 @@ class ListViewTest(TestCase):
953954
Why these points? Skip ahead to <<appendix_Django_Class-Based_Views>>, and I'll show how
954955
they are sufficient to ensure that our views are still correct if we refactor
955956
them to start using class-based views.((("", startref="FDVduplicate15")))((("", startref="UIduplicate15")))
957+
// CSANAD: We might want to revisit these again after updating/reviewing the
958+
// Django Class Based Views.
956959
957960
958961
Next we'll try to make our data validation more friendly by using a bit

0 commit comments

Comments
 (0)