Exemplo n.º 1
0
 def test_form_valid_redirects_to_claim_url_if_save_and_email(self):
     view = UpdateContact()
     view.request = RequestFactory().post('/')
     view.request.POST.update({'save-and-email': ''})
     view.object = mock.Mock(id=3)
     assert view.get_success_url() == reverse('contact_claim_account',
                                              args=(3, ))
Exemplo n.º 2
0
def test_update_contact_form_invalid_adds_a_message_to_messages(rf):
    view = UpdateContact()
    view.object = mock.MagicMock()
    r = rf.get('/')
    view.request = r
    form = mock.MagicMock()
    with mock.patch('contacts.views.contact_info.messages') as messages:
        view.form_invalid(form)
        messages.error.assert_called_once_with(r, 'Contact data not valid, \
                please check and try again.')
Exemplo n.º 3
0
def test_update_contact_form_invalid_adds_a_message_to_messages(rf):
    view = UpdateContact()
    view.object = mock.MagicMock()
    r = rf.get('/')
    view.request = r
    form = mock.MagicMock()
    with mock.patch('contacts.views.contact_info.messages') as messages:
        view.form_invalid(form)
        messages.error.assert_called_once_with(
            r, 'Contact data not valid, \
                please check and try again.')
Exemplo n.º 4
0
 def test_form_valid_redirects_to_claim_url_if_save_and_email(self):
     view = UpdateContact()
     view.request = RequestFactory().post('/')
     view.request.POST.update({'save-and-email': ''})
     view.object = mock.Mock(id=3)
     assert view.get_success_url() == reverse('contact_claim_account', args=(3,))