def test_post_sends_error_message(self, put, error):
     put.return_value = Mock(status_code=403, text=u'error')
     data = {
         "old": "old",
         "new": "new",
         "confirm": "new",
     }
     request = RequestFactory().post("/", data)
     request.session = {'tsuru_token': 'tokentest'}
     ChangePassword.as_view()(request)
     error.assert_called_with(request, u'error', fail_silently=True)
Esempio n. 2
0
 def test_post_sends_error_message(self, put, error):
     put.return_value = Mock(status_code=403, text=u'error')
     data = {
         "old": "old",
         "new": "new",
         "confirm": "new",
     }
     request = RequestFactory().post("/", data)
     request.session = {'tsuru_token': 'tokentest'}
     ChangePassword.as_view()(request)
     error.assert_called_with(request, u'error', fail_silently=True)
 def test_post_sends_success_message(self, put, success):
     put.return_value = Mock(status_code=200)
     data = {
         "old": "old",
         "new": "new",
         "confirm": "new",
     }
     request = RequestFactory().post("/", data)
     request.session = {'tsuru_token': 'tokentest'}
     ChangePassword.as_view()(request)
     success.assert_called_with(request, u'Password successfully updated!', fail_silently=True)
Esempio n. 4
0
 def test_post_sends_success_message(self, put, success):
     put.return_value = Mock(status_code=200)
     data = {
         "old": "old",
         "new": "new",
         "confirm": "new",
     }
     request = RequestFactory().post("/", data)
     request.session = {'tsuru_token': 'tokentest'}
     ChangePassword.as_view()(request)
     success.assert_called_with(request, u'Password successfully updated!')
Esempio n. 5
0
 def test_get(self):
     request = RequestFactory().get("/")
     request.session = {"tsuru_token": "ble"}
     response = ChangePassword.as_view()(request)
     self.assertIn('auth/change_password.html', response.template_name)
     self.assertIsInstance(response.context_data['form'],
                           ChangePasswordForm)
Esempio n. 6
0
 def test_login_required(self, get):
     get.return_value = Mock(status_code=200)
     request = RequestFactory().get("/")
     request.session = {}
     response = ChangePassword.as_view()(request)
     self.assertEqual(302, response.status_code)
     self.assertEqual("%s?next=%s" % (reverse('login'), request.path), response.items()[1][1])
 def test_get(self):
     request = RequestFactory().get("/")
     request.session = {"tsuru_token": "ble"}
     response = ChangePassword.as_view()(request)
     self.assertIn('auth/change_password.html',
                   response.template_name)
     self.assertIsInstance(response.context_data['form'],
                           ChangePasswordForm)
 def test_post(self, put, error):
     data = {
         "old": "old",
         "new": "new",
         "confirm": "new",
     }
     request = RequestFactory().post("/", data)
     request.session = {'tsuru_token': 'tokentest'}
     response = ChangePassword.as_view()(request)
     headers = {'authorization': 'tokentest'}
     url = "{0}/users/password".format(settings.TSURU_HOST)
     put.assert_called_with(url, data=json.dumps(data), headers=headers)
     self.assertEqual(302, response.status_code)
     self.assertEqual('/auth/change-password/', response.items()[1][1])
Esempio n. 9
0
 def test_post(self, put, error):
     data = {
         "old": "old",
         "new": "new",
         "confirm": "new",
     }
     request = RequestFactory().post("/", data)
     request.session = {'tsuru_token': 'tokentest'}
     response = ChangePassword.as_view()(request)
     headers = {'authorization': 'tokentest'}
     url = "{0}/users/password".format(settings.TSURU_HOST)
     put.assert_called_with(url, data=json.dumps(data), headers=headers)
     self.assertEqual(302, response.status_code)
     self.assertEqual('/auth/change-password/', response.items()[1][1])
 def test_login_required(self):
     request = RequestFactory().get("/")
     request.session = {}
     response = ChangePassword.as_view()(request)
     self.assertEqual(302, response.status_code)
     self.assertEqual(reverse('login'), response.items()[1][1])
Esempio n. 11
0
 def test_login_required(self):
     request = RequestFactory().get("/")
     request.session = {}
     response = ChangePassword.as_view()(request)
     self.assertEqual(302, response.status_code)
     self.assertEqual(reverse('login'), response.items()[1][1])