Django Class-based view pass custom request

You’re almost there. as_view() creates the functional view version of the CBV that can be handed a request:

@patch('lists.views.NewListForm')
class NewListViewUnitTest(unittest.TestCase):
    # ...
    def test_passes_POST_data_to_NewListForm(self, mockNewListForm):
        NewListView.as_view()(self.request)
        mockNewListForm.assert_called_once_with(data=self.request.POST)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top