mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
gitweb: tests: Use common fixtures for testing actions module
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
parent
3526099c03
commit
344915d84e
@ -3,10 +3,7 @@
|
|||||||
Test module for gitweb module operations.
|
Test module for gitweb module operations.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import imp
|
|
||||||
import json
|
import json
|
||||||
import pathlib
|
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from django.forms import ValidationError
|
from django.forms import ValidationError
|
||||||
@ -19,29 +16,13 @@ REPO_DATA = {
|
|||||||
'access': 'private',
|
'access': 'private',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actions_name = 'gitweb'
|
||||||
def _action_file():
|
|
||||||
"""Return the path to the 'gitweb' actions file."""
|
|
||||||
current_directory = pathlib.Path(__file__).parent
|
|
||||||
return str(current_directory / '..' / '..' / '..' / '..' / 'actions' /
|
|
||||||
'gitweb')
|
|
||||||
|
|
||||||
|
|
||||||
gitweb_actions = imp.load_source('gitweb', _action_file())
|
@pytest.fixture(autouse=True)
|
||||||
|
def fixture_set_repo_path(actions_module, tmpdir):
|
||||||
|
"""Set a repository path in the actions module."""
|
||||||
@pytest.fixture(name='call_action')
|
actions_module.GIT_REPO_PATH = str(tmpdir)
|
||||||
def fixture_call_action(tmpdir, capsys):
|
|
||||||
"""Run actions with custom repo root path."""
|
|
||||||
|
|
||||||
def _call_action(args, **kwargs):
|
|
||||||
gitweb_actions.GIT_REPO_PATH = str(tmpdir)
|
|
||||||
with patch('argparse._sys.argv', ['gitweb'] + args):
|
|
||||||
gitweb_actions.main()
|
|
||||||
captured = capsys.readouterr()
|
|
||||||
return captured.out
|
|
||||||
|
|
||||||
return _call_action
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name='existing_repo')
|
@pytest.fixture(name='existing_repo')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user