Joseph Nuthalapati 658e260d23
mediawiki: Add action to set domain name
- 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>
2020-10-31 22:04:10 -07:00

54 lines
1.4 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Common test fixtures for MediaWiki.
"""
import shutil
import importlib
import pathlib
import types
from unittest.mock import patch
import pytest
current_directory = pathlib.Path(__file__).parent
def _load_actions_module():
actions_file_path = str(current_directory / '..' / '..' / '..' / '..' /
'actions' / 'mediawiki')
loader = importlib.machinery.SourceFileLoader('mediawiki',
actions_file_path)
module = types.ModuleType(loader.name)
loader.exec_module(module)
return module
actions = _load_actions_module()
@pytest.fixture(name='call_action')
def fixture_call_action(capsys, conf_file):
"""Run actions with custom root path."""
def _call_action(module_name, args, **kwargs):
actions.CONF_FILE = conf_file
with patch('argparse._sys.argv', [module_name] + args):
actions.main()
captured = capsys.readouterr()
return captured.out
return _call_action
@pytest.fixture(name='conf_file')
def fixture_conf_file(tmp_path):
"""Uses a dummy configuration file."""
settings_file_name = 'FreedomBoxSettings.php'
conf_file = tmp_path / settings_file_name
conf_file.touch()
shutil.copyfile(
str(current_directory / '..' / 'data' / 'etc' / 'mediawiki' /
settings_file_name), str(conf_file))
return str(conf_file)