Пример #1
0
    def test_that_it_correctly_invokes_the_form_processor(self, mock_render, mock_forms_func):
        mock_forms_func.return_value = (invalid_form(), invalid_form(), invalid_form())

        request = rf.post('/events/create/', self.data)
        request.user = Mock()
        views.create(request)

        mock_forms_func.assert_called_with(query_dict_from(self.data))
    def test_that_it_correctly_invokes_the_form_processor(self, mock_render, mock_forms_func):
        mock_forms_func.return_value = (invalid_form(), invalid_form(), invalid_form())

        request = rf.post('/events/create/', self.data)
        request.user = Mock()
        views.create(request)

        mock_forms_func.assert_called_with(query_dict_from(self.data))
Пример #3
0
    def test_that_valid_data_creates_an_event_and_venue_and_redirects(self, mock_create_func, 
            mock_forms_func, mock_bsd_email_func):
        mock_forms_func.return_value = (self.mock_ef, self.mock_vf, self.mock_lf)
        mock_create_func.return_value = (mock_persisted_event(id = 1), None)
        mock_user = Mock()

        request = rf.post('/events/create/', self.data)
        request.user = mock_user
        response = views.create(request)

        mock_bsd_email_func.assert_called_with(mock_user, self.mock_lf)
        mock_create_func.assert_called_with(mock_user, self.mock_ef, self.mock_vf)
        assert_redirects_to_named_url(response, 'event', kwargs = {'event_id': 1})
    def test_that_valid_data_creates_an_event_and_venue_and_redirects(self, mock_create_func, 
            mock_forms_func, mock_bsd_email_func):
        mock_forms_func.return_value = (self.mock_ef, self.mock_vf, self.mock_lf)
        mock_create_func.return_value = (mock_persisted_event(id = 1), None)
        mock_user = Mock()

        request = rf.post('/events/create/', self.data)
        request.user = mock_user
        response = views.create(request)

        mock_bsd_email_func.assert_called_with(mock_user, self.mock_lf)
        mock_create_func.assert_called_with(mock_user, self.mock_ef, self.mock_vf)
        assert_redirects_to_named_url(response, 'event', kwargs = {'event_hash': 'e25388fde'})
Пример #5
0
    def test_that_invalid_data_causes_a_rerender_of_the_new_template(self, mock_render, mock_create_func,
            mock_forms_func, mock_bsd_email_func):
        ef = invalid_form()
        vf = invalid_form()
        lf = invalid_form()
        mock_forms_func.return_value = (ef, vf, lf)

        request = rf.post('/events/create/', self.data)
        request.user = Mock()
        response = views.create(request)

        eq_(mock_create_func.call_args_list, [])
        eq_(mock_bsd_email_func.call_args_list, [])
        mock_render.assert_called_with(request, ef, vf, lf)
    def test_that_invalid_data_causes_a_rerender_of_the_new_template(self, mock_render, mock_create_func,
            mock_forms_func, mock_bsd_email_func):
        ef = invalid_form()
        vf = invalid_form()
        lf = invalid_form()
        mock_forms_func.return_value = (ef, vf, lf)

        request = rf.post('/events/create/', self.data)
        request.user = Mock()
        response = views.create(request)

        eq_(mock_create_func.call_args_list, [])
        eq_(mock_bsd_email_func.call_args_list, [])
        mock_render.assert_called_with(request, ef, vf, lf)
Пример #7
0
 def test_that_it_rejects_get_requests(self):
     request = rf.get('/events/create/')
     response = views.create(request)
     self.assertEqual(405, response.status_code)
 def test_that_it_rejects_get_requests(self):
     request = rf.get('/events/create/')
     response = views.create(request)
     self.assertEqual(405, response.status_code)