@@ -886,7 +886,8 @@ real app.
886
886
887
887
We have one unit test file for each of our key source code files. Here's
888
888
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
890
891
891
892
.What to Test in Views
892
893
******************************************************************************
@@ -898,7 +899,7 @@ shows just the key tests and assertions):
898
899
----
899
900
class ListViewTest(TestCase):
900
901
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>
902
903
self.assertTemplateUsed(response, 'list.html') #<2>
903
904
def test_passes_correct_list_to_template(self):
904
905
self.assertEqual(response.context['list'], correct_list) #<3>
@@ -924,7 +925,7 @@ class ListViewTest(TestCase):
924
925
def test_for_invalid_input_shows_error_on_page(self):
925
926
self.assertContains(response, escape(EMPTY_ITEM_ERROR)) #<7>
926
927
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>
928
929
self.assertTemplateUsed(response, 'list.html')
929
930
self.assertEqual(Item.objects.all().count(), 1)
930
931
----
@@ -933,10 +934,10 @@ class ListViewTest(TestCase):
933
934
934
935
<1> Use the Django Test Client.
935
936
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
937
939
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.
940
941
941
942
<4> Check that any forms are of the correct class.
942
943
@@ -953,6 +954,8 @@ class ListViewTest(TestCase):
953
954
Why these points? Skip ahead to <<appendix_Django_Class-Based_Views>>, and I'll show how
954
955
they are sufficient to ensure that our views are still correct if we refactor
955
956
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.
956
959
957
960
958
961
Next we'll try to make our data validation more friendly by using a bit
0 commit comments