mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-11 08:23:49 +00:00
- Set domain name during app setup - Improve tests for settings. Prefer to call functions in plinth which invoke actions than test actions directly. - Also, '$wgServer' is not a domain name since it also includes the protocol. - Add domain selection form. Make server url a text input field. - Added a functional test to set the value of server url to the value provided by FREEDOMBOX_URL before doing running any other tests. - Make server url setting a pre-requisite. Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> [sunil: Squash commits as they were fixing themselves] [sunil: Simplify configuration reading] [sunil: Use 'server_url' terminology consistently] [sunil: cosmetic: Minor styling] [sunil: Update test_settings.py to use fixture pattern] [sunil: Remove seemingly incorrectly used aria-describedby attribute] [sunil: Don't rely solely on env variable value in functional tests] [sunil: Fix issue with http/https mismatch when checking site availability] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Test module for MediaWiki utility functions.
|
|
"""
|
|
|
|
import pathlib
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from plinth.modules import mediawiki
|
|
|
|
|
|
@pytest.fixture(name='test_configuration', autouse=True)
|
|
def fixture_test_configuration(call_action, conf_file):
|
|
"""Use a separate MediaWiki configuration for tests.
|
|
|
|
Uses local FreedomBoxStaticSettings.php, a temp version of
|
|
FreedomBoxSettings.php and patches actions.superuser_run with the fixture
|
|
call_action
|
|
|
|
"""
|
|
data_directory = pathlib.Path(__file__).parent.parent / 'data'
|
|
static_config_file = str(data_directory / 'etc' / 'mediawiki' /
|
|
mediawiki.STATIC_CONFIG_FILE.split('/')[-1])
|
|
with patch('plinth.modules.mediawiki.STATIC_CONFIG_FILE',
|
|
static_config_file), \
|
|
patch('plinth.modules.mediawiki.USER_CONFIG_FILE', conf_file), \
|
|
patch('plinth.actions.superuser_run', call_action):
|
|
yield
|
|
|
|
|
|
def test_default_skin():
|
|
"""Test getting and setting the default skin."""
|
|
assert mediawiki.get_default_skin() == 'timeless'
|
|
new_skin = 'vector'
|
|
mediawiki.set_default_skin(new_skin)
|
|
assert mediawiki.get_default_skin() == new_skin
|
|
|
|
|
|
def test_server_url():
|
|
"""Test getting and setting $wgServer."""
|
|
assert mediawiki.get_server_url() == 'freedombox.local'
|
|
new_server_url = 'mydomain.freedombox.rocks'
|
|
mediawiki.set_server_url(new_server_url)
|
|
assert mediawiki.get_server_url() == new_server_url
|