Beispiel #1
0
 def test_list_with_trailing_slash_redirects_correctly(self):
     response = self.client.get(
         '/data-sets/?data-type=aaa',
         HTTP_AUTHORIZATION=('Bearer dev-data-set-query-token'),
         follow=True)
     assert_redirects(response, '/data-sets?data-type=aaa',
                      status_code=301, target_status_code=200)
Beispiel #2
0
 def test_profile_update_requires_authentication(self):
     url = '/accounts/profile/'
     data = {
         'name': 'John Donne',
     }
     response = self.client.post(url, data)
     assert_redirects(response, utils.get_login_url(url))
 def test_unregisted_email_POST_request_fails(self):
     payload = {
         'email': '*****@*****.**',
     }
     response = self.client.post('/accounts/password/reset/', payload)
     assert_redirects(response, reverse('password_reset_done'))
     eq_(len(mail.outbox), 0)
 def test_valid_POST_request_is_successful(self):
     payload = {
         'new_password1': 'hello',
         'new_password2': 'hello',
     }
     response = self.client.post(self._url, payload)
     assert_redirects(response, reverse('password_reset_complete'))
 def test_login_page_succeeds(self):
     fixtures.get_user('hello', email='*****@*****.**')
     payload  = {
         'username': '******',
         'password': '******',
     }
     response = self.client.post('/accounts/login/', payload)
     assert_redirects(response, '/accounts/profile/')
 def test_registration_is_successful(self):
     response = self.client.post('/accounts/register/', {
         'email': '*****@*****.**',
         'password1': 'hello!',
         'password2': 'hello!',
     })
     assert_redirects(response, '/accounts/register/complete/')
     _teardown_profiles()
 def test_post_request_succeds(self):
     url = '/accounts/password/change/'
     payload = {
         'old_password': '******',
         'new_password1': 'hello123',
         'new_password2': 'hello123',
     }
     response = self.client.post(url, payload)
     assert_redirects(response, reverse('password_change_done'))
 def test_post_request_requires_authentication(self):
     url = '/accounts/password/change/'
     payload = {
         'old_password': '******',
         'new_password1': 'hello123',
         'new_password2': 'hell0123',
     }
     response = self.client.post(url, payload)
     assert_redirects(response, utils.get_login_url(url))
Beispiel #9
0
 def test_post_valid_payload_succeds(self):
     url = '/admin/profiles/profile/inviter/'
     payload = _get_payload([('Alpha', '*****@*****.**')])
     response = self.client.post(url, payload)
     assert_redirects(response, '/admin/profiles/profile/')
     user = User.objects.get(email='*****@*****.**')
     ok_(user.username)
     eq_(user.profile.name, 'Alpha')
     ok_(user.profile.slug)
 def test_public_dashboards_with_forward_slash_redirects(
         self, spotlightify_patch):
     resp = self.client.get('/public/dashboards/',
                            {'slug': 'my_first_slug'})
     assert_redirects(
         resp,
         'http://testserver/public/dashboards?slug=my_first_slug',
         status_code=301,
         target_status_code=404)
Beispiel #11
0
 def test_public_dashboards_with_forward_slash_redirects(
         self,
         spotlightify_patch):
     resp = self.client.get(
         '/public/dashboards/', {'slug': 'my_first_slug'})
     assert_redirects(
         resp,
         'http://testserver/public/dashboards?slug=my_first_slug',
         status_code=301,
         target_status_code=404)
Beispiel #12
0
 def test_profile_ignores_invaid_values(self):
     url = '/accounts/profile/'
     data = {
         'email': '*****@*****.**',
     }
     response = self.client.post(url, data)
     assert_redirects(response, '/accounts/profile/')
     values = (User.objects.values('email')
               .get(username='******'))
     eq_(values, {'email': '*****@*****.**'})
 def test_valid_request_succeeds(self):
     fixtures.get_user('hello', email='*****@*****.**')
     payload = {
         'email': '*****@*****.**',
     }
     response = self.client.post('/accounts/password/reset/', payload)
     assert_redirects(response, reverse('password_reset_done'))
     eq_(len(mail.outbox), 1)
     expected_url = '%s/accounts/password/reset/confirm/' % settings.SITE_URL
     ok_(expected_url in mail.outbox[0].body)
Beispiel #14
0
 def test_profile_form_update_is_successful(self):
     url = '/accounts/profile/'
     data = {
         'first_name': 'John',
         'last_name': 'Donne',
     }
     response = self.client.post(url, data)
     assert_redirects(response, '/accounts/profile/')
     values = (User.objects.values('first_name', 'last_name')
               .get(username='******'))
     eq_(values, data)
Beispiel #15
0
 def test_profile_ignores_invaid_values(self):
     profile, is_new = Profile.objects.get_or_create(user=self.user)
     url = '/accounts/profile/'
     data = {
         'email': '*****@*****.**',
         'availability': Profile.NO_AVAILABILITY,
     }
     data.update(_get_profilelink_inline_payload(profile.pk))
     response = self.client.post(url, data)
     assert_redirects(response, '/accounts/profile/')
     values = (User.objects.values('email')
               .get(username='******'))
     eq_(values, {'email': '*****@*****.**'})
Beispiel #16
0
 def test_profile_form_update_is_successful(self):
     profile, is_new = Profile.objects.get_or_create(user=self.user)
     url = '/accounts/profile/'
     data = {
         'first_name': 'John',
         'last_name': 'Donne',
         'availability': Profile.NO_AVAILABILITY,
     }
     data.update(_get_profilelink_inline_payload(profile.pk))
     response = self.client.post(url, data)
     assert_redirects(response, '/accounts/profile/')
     profile = Profile.objects.get(user__username='******')
     eq_(profile.name, 'John Donne')
     eq_(profile.user.first_name, 'John')
     eq_(profile.user.last_name, 'Donne')
Beispiel #17
0
 def test_profile_updates_inline_models(self):
     profile, is_new = Profile.objects.get_or_create(user=self.user)
     url = '/accounts/profile/'
     data = {
         'name': '',
         'availability': Profile.NO_AVAILABILITY,
     }
     data_list = [{'name': 'Github', 'url': 'http://github.com/'}]
     data.update(_get_profilelink_inline_payload(
         profile.pk, data_list=data_list))
     response = self.client.post(url, data)
     assert_redirects(response, '/accounts/profile/')
     values = list(ProfileLink.objects.values('name', 'url')
                   .filter(profile=profile))
     eq_(values, [{'name': 'Github', 'url': 'http://github.com/'}])
Beispiel #18
0
 def test_blog_index(self):
     # Blog front page should redirect to the latest public page.
     response = self.client.get('/blog/')
     eq_(response.status_code, 302)
     latest = Post.objects.public().latest()
     assert_redirects(response, latest.get_absolute_url())
Beispiel #19
0
 def test_profile_requires_authentication(self):
     url = '/accounts/profile/'
     response = self.client.get(url)
     assert_redirects(response, utils.get_login_url(url))
Beispiel #20
0
 def test_people_list_requires_auth(self):
     url = '/people/'
     response = self.client.get(url)
     assert_redirects(response, utils.get_login_url(url))
Beispiel #21
0
 def test_people_page_detail_requires_auth(self):
     user = fixtures.get_user('us-ignite')
     fixtures.get_profile(user=user, name='us ignite', slug='ignite')
     response = self.client.get('/people/ignite/')
     assert_redirects(response, utils.get_login_url('/people/ignite/'))
     _teardown_profiles()
 def test_page_requires_authentication(self):
     url = '/accounts/password/change/done/'
     response = self.client.get(url)
     assert_redirects(response, utils.get_login_url(url))