diff --git a/plinth/modules/users/tests/test_functional.py b/plinth/modules/users/tests/test_functional.py index 0ccfb2fed..4400833d3 100644 --- a/plinth/modules/users/tests/test_functional.py +++ b/plinth/modules/users/tests/test_functional.py @@ -57,7 +57,7 @@ def fixture_background(session_browser): """Login.""" functional.login(session_browser) yield - _set_language(session_browser, _language_codes['None']) + functional.user_set_language(session_browser, _language_codes['None']) def test_create_user(session_browser): @@ -146,7 +146,7 @@ def test_update_user(session_browser): @pytest.mark.parametrize('language_code', _language_codes.values()) def test_change_language(session_browser, language_code): """Test changing the language.""" - _set_language(session_browser, language_code) + functional.user_set_language(session_browser, language_code) assert _check_language(session_browser, language_code) @@ -298,15 +298,6 @@ def _get_email(browser, username): return browser.find_by_id('id_email').value -def _set_language(browser, language_code): - username = functional.config['DEFAULT']['username'] - functional.visit(browser, '/plinth/sys/users/{}/edit/'.format(username)) - browser.find_by_xpath('//select[@id="id_language"]//option[@value="' + - language_code + '"]').first.click() - browser.find_by_id('id_confirm_password').fill(_admin_password) - functional.submit(browser, form_class='form-update') - - def _check_language(browser, language_code): functional.nav_to_module(browser, 'config') return browser.find_by_css('.app-titles').first.find_by_tag( diff --git a/plinth/tests/functional/__init__.py b/plinth/tests/functional/__init__.py index 2d652646d..3f771404f 100644 --- a/plinth/tests/functional/__init__.py +++ b/plinth/tests/functional/__init__.py @@ -679,6 +679,17 @@ def user_exists(browser, name): return len(links) == 1 +def user_set_language(browser, language_code): + """Change user's preferred UI language.""" + username = config['DEFAULT']['username'] + admin_password = config['DEFAULT']['password'] + visit(browser, '/plinth/sys/users/{}/edit/'.format(username)) + browser.find_by_xpath('//select[@id="id_language"]//option[@value="' + + language_code + '"]').first.click() + browser.find_by_id('id_confirm_password').fill(admin_password) + submit(browser, form_class='form-update') + + class BaseAppTests: """Base class for common functional tests.