Esempio n. 1
0
 def test_empty_post_request_fails(self, mock_get):
     mock_profile = Mock(spec=Profile)()
     mock_get.return_value = mock_profile
     request = utils.get_request(
         'post', '/contact/foo/', data={}, user=utils.get_user_mock())
     response = views.contact_user(request, 'foo')
     ok_(response.context_data['form'].errors)
Esempio n. 2
0
 def test_get_request_is_valid(self, mock_get):
     mock_profile = Mock(spec=Profile)()
     mock_get.return_value = mock_profile
     request = utils.get_request(
         'get', '/contact/foo/', user=utils.get_user_mock())
     response = views.contact_user(request, 'foo')
     eq_(response.status_code, 200)
     eq_(response.template_name, 'relay/contact_user.html')
     eq_(sorted(response.context_data), ['form', 'object'])
Esempio n. 3
0
 def test_valid_post_request_succeeds(self, mock_contact, mock_get):
     mock_profile = Mock(spec=Profile)()
     mock_profile.get_absolute_url.return_value = '/accounts/user-slug/'
     mock_profile.display_email = 'info@us_ignite.org'
     mock_get.return_value = mock_profile
     data = {
         'title': 'Hi there!',
         'body': 'The app is quite interesting',
     }
     request = utils.get_request(
         'post', '/contact/foo/', data=data, user=utils.get_user_mock())
     request.user.email = '*****@*****.**'
     request._messages = utils.TestMessagesBackend(request)
     response = views.contact_user(request, 'foo')
     eq_(response.status_code, 302)
     eq_(response['Location'], '/accounts/user-slug/')
     mock_contact.assert_called_once()
Esempio n. 4
0
 def test_contact_user_requires_login(self):
     request = utils.get_request(
         'get', '/contact/foo/', user=utils.get_anon_mock())
     response = views.contact_user(request, 'foo')
     eq_(response.status_code, 302)
     eq_(response['Location'], utils.get_login_url('/contact/foo/'))