From f4c31b28efcfd94221cd058c206446dff027d346 Mon Sep 17 00:00:00 2001 From: Jari Voutilainen Date: Thu, 10 Mar 2016 13:59:46 +0200 Subject: [PATCH] added some tests --- ckan/tests/controllers/test_user.py | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/ckan/tests/controllers/test_user.py b/ckan/tests/controllers/test_user.py index b7e8fe7bdb8..fc3198ff74f 100644 --- a/ckan/tests/controllers/test_user.py +++ b/ckan/tests/controllers/test_user.py @@ -246,6 +246,37 @@ def test_edit_user(self): assert_equal(user.about, 'new about') assert_equal(user.activity_streams_email_notifications, True) + def test_email_change_without_password(self): + + app = self._get_test_app() + env, response, user = _get_user_edit_page(app) + + form = response.forms['user-edit-form'] + + # new values + form['email'] = 'new@example.com' + + # factory returns user with password 'pass' + form.fields['old_password'][0].value = 'wrong-pass' + + response = webtest_submit(form, 'save', status=200, extra_environ=env) + assert_true('Old Password: incorrect password' in response) + + def test_email_change_with_password(self): + app = self._get_test_app() + env, response, user = _get_user_edit_page(app) + + form = response.forms['user-edit-form'] + + # new values + form['email'] = 'new@example.com' + + # factory returns user with password 'pass' + form.fields['old_password'][0].value = 'pass' + + response = submit_and_follow(app, form, env, 'save') + assert_true('Profile updated' in response) + def test_perform_reset_for_key_change(self): password = 'password' params = {'password1': password, 'password2': password}