- self.instance.list = for_list
- return super().save()
-
-
class NewListForm(ItemForm):
@@ -52,8 +47,3 @@ class ExistingListItemForm(ItemForm):
e.error_dict = {'text': [DUPLICATE_ITEM_ERROR]}
self._update_errors(e)
-
-
- def save(self):
- return forms.models.ModelForm.save(self)
-
Removing the Old Implementation of the View
We can now completely remove the old
new_list
view, and rename
new_list2
to
new_list
:
lists/tests/test_views.py.
-from lists.views import new_list, new_list2
+from lists.views import new_list
class HomePageTest(TestCase):
@@ -75,7 +75,7 @@ class NewListViewIntegratedTest(TestCase):
request = HttpRequest()
request.user = User.objects.create(email=
'a@b.com')
request.POST['text'] = 'new list item'
- new_list2(request)
+ new_list(request)
list_ = List.objects.first()
self.assertEqual(list_.owner, request.user)
@@ -91,21 +91,21 @@ class NewListViewUnitTest(unittest.TestCase):
def test_passes_POST_data_to_NewListForm(self, mockNewListForm):
- new_list2(self.request)
+ new_list(self.request)
[.. several more]
lists/urls.py.
--- a/lists/urls.py
+++ b/lists/urls.py
@@ -2,6 +2,6 @@ from django.conf.urls import patterns, url
urlpatterns = patterns('',
url(r'^(\d+)/$', 'lists.views.view_list', name='view_list'),
- url(r'^new$', 'lists.views.new_list2', name='new_list'),
360
|
Chapter 19: Test Isolation, and “Listening to Your Tests”