def test_post(self, form_valid_mock: MagicMock, get_form_mock: MagicMock, _get_form_class_data_mock: MagicMock, _get_task_mock: MagicMock): request = self.factory.post(self.fake_path, self.post_data) view = TaskView() view = setup_view(view, request, **self.task_data) view.post(request) _get_task_mock.assert_called_once_with( new=False, project_id=str(self.post_data.get('_project_id')), task_id=str(self.post_data.get('_task_id'))) _get_form_class_data_mock.assert_any_call() get_form_mock.assert_any_call()
def test_post_no_project_id(self): del self.post_data['_project_id'] request = self.factory.post(self.fake_path, self.post_data) view = TaskView() view = setup_view(view, request, **self.task_data) response = view.post(request) self.assertEqual(response.status_code, 400)
def test_post_no_form( self, get_success_url_mock: MagicMock, _send_task_mock: MagicMock, unpack_post_mock: MagicMock, get_form_mock: MagicMock, _get_form_class_data_mock: MagicMock, _get_task_mock: MagicMock ): get_form_mock.return_value = None get_success_url_mock.return_value = self.redirect_path request = self.factory.post(self.fake_path, self.post_data) view = TaskView() view = setup_view(view, request, **self.task_data) response = view.post(request) self.assertEqual(response.status_code, 302) get_success_url_mock.assert_any_call() # TODO: FIXME # _send_task_mock.assert_called_with(unpack_post_mock) # TODO: FIXME # unpack_post_mock.assert_called_once_with(self.post_data) get_form_mock.assert_any_call() _get_form_class_data_mock.assert_any_call() _get_task_mock.assert_called_with( new=False, project_id=str(self.post_data.get('_project_id')), task_id=str(self.post_data.get('_task_id')) )