Пример #1
0
    def test_non_matching_new_passwords_fail(self):
        form = PasswordChangeForm(self.request,
                                  data={
                                      'old_password': '******',
                                      'new_password': '******',
                                      'new_password_confirmation': 'new2'
                                  })

        self.assertFalse(form.is_valid())
        self.assertEqual(len(responses.calls), 0)
    def test_non_matching_new_passwords_fail(self, mock_api_client):
        conn = mock_api_client.get_connection()

        form = PasswordChangeForm(
            None,
            data={
                'old_password': '******',
                'new_password': '******',
                'new_password_confirmation': 'new2'
            }
        )

        self.assertFalse(form.is_valid())
        self.assertFalse(conn.change_password.post.called)
    def test_change_password(self, mock_api_client):
        conn = mock_api_client.get_connection()

        form = PasswordChangeForm(
            None,
            data={
                'old_password': '******',
                'new_password': '******',
                'new_password_confirmation': 'new'
            }
        )

        self.assertTrue(form.is_valid())
        conn.change_password.post.assert_called_once_with({
            'old_password': '******', 'new_password': '******'
        })
Пример #4
0
    def test_change_password(self):
        responses.add(responses.POST,
                      urljoin(settings.API_URL, 'change_password'),
                      status=204,
                      content_type='application/json')

        form = PasswordChangeForm(self.request,
                                  data={
                                      'old_password': '******',
                                      'new_password': '******',
                                      'new_password_confirmation': 'new'
                                  })

        self.assertTrue(form.is_valid())
        self.assertEqual(
            json.loads(responses.calls[0].request.body.decode('utf-8')), {
                'old_password': '******',
                'new_password': '******'
            })