Mercurial > kallithea
changeset 8806:3672a8e4584a
tests: drop vcs setup_package
Repos are always created before running vcs tests, and the SCMFetcher code was
thus effectively dead.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Mon, 14 Dec 2020 17:56:31 +0100 |
parents | 8170c8a1a1d3 |
children | 1097603f5499 |
files | kallithea/tests/fixture.py kallithea/tests/vcs/__init__.py kallithea/tests/vcs/utils.py |
diffstat | 3 files changed, 0 insertions(+), 94 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/tests/fixture.py Mon Dec 14 17:53:21 2020 +0100 +++ b/kallithea/tests/fixture.py Mon Dec 14 17:56:31 2020 +0100 @@ -43,7 +43,6 @@ from kallithea.tests.base import (GIT_REPO, HG_REPO, IP_ADDR, TEST_USER_ADMIN_EMAIL, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, TEST_USER_REGULAR2_EMAIL, TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS, TEST_USER_REGULAR_EMAIL, TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS, TESTS_TMP_PATH, invalidate_all_caches) -from kallithea.tests.vcs import setup_package log = logging.getLogger(__name__) @@ -404,9 +403,6 @@ tar.extractall(os.path.join(TESTS_TMP_PATH, GIT_REPO)) tar.close() - # LOAD VCS test stuff - setup_package() - def create_test_index(repo_location, config, full_index): """
--- a/kallithea/tests/vcs/__init__.py Mon Dec 14 17:53:21 2020 +0100 +++ b/kallithea/tests/vcs/__init__.py Mon Dec 14 17:56:31 2020 +0100 @@ -9,49 +9,13 @@ need to set the correct backend to use by setting the ``backend_alias`` property, which should correspond to one of the keys from ``vcs.backends.BACKENDS``. - -For each SCM we run tests for, we need some repository. We would use -repositories location provided in test suite defaults - see ``conf`` -module for more detail. We simply try to check if repository at -certain location exists, if not we would try to fetch them. At -``test_vcs`` or ``test_common`` we run unit tests common for each -repository type and for example specific mercurial tests are located -at ``test_hg`` module. """ import os -from kallithea.tests.base import GIT_REMOTE_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, TEST_HG_REPO -from kallithea.tests.vcs.utils import SCMFetcher - # Base directory for the VCS tests. VCS_TEST_MODULE_BASE_DIR = os.path.abspath(os.path.dirname(__file__)) # Path to user configuration file used during tests. TEST_USER_CONFIG_FILE = os.path.join(VCS_TEST_MODULE_BASE_DIR, 'aconfig') - - -def setup_package(): - """ - Prepares whole package for tests which mainly means it would try to fetch - test repositories or use already existing ones. - """ - fetchers = { - 'hg': { - 'alias': 'hg', - 'test_repo_path': TEST_HG_REPO, - 'remote_repo': HG_REMOTE_REPO, - 'clone_cmd': 'hg clone --insecure', - }, - 'git': { - 'alias': 'git', - 'test_repo_path': TEST_GIT_REPO, - 'remote_repo': GIT_REMOTE_REPO, - 'clone_cmd': 'git clone --bare', - }, - } - - for scm, fetcher_info in fetchers.items(): - fetcher = SCMFetcher(**fetcher_info) - fetcher.setup()
--- a/kallithea/tests/vcs/utils.py Mon Dec 14 17:53:21 2020 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -""" -Utilities for tests only. These are not or should not be used normally - -functions here are crafted as we don't want to use ``vcs`` to verify tests. -""" -import os -import sys -from subprocess import Popen - - -def run_command(cmd, args): - """ - Runs command on the system with given ``args``. - """ - command = ' '.join((cmd, args)) - p = Popen(command, shell=True) - status = os.waitpid(p.pid, 0)[1] - return status - - -def eprint(msg): - """ - Prints given ``msg`` into sys.stderr as nose test runner hides all output - from sys.stdout by default and if we want to pipe stream somewhere we don't - need those verbose messages anyway. - Appends line break. - """ - sys.stderr.write(msg) - sys.stderr.write('\n') - - -class SCMFetcher(object): - - def __init__(self, alias, test_repo_path, remote_repo, clone_cmd): - """ - :param clone_cmd: command which would clone remote repository; pass - only first bits - remote path and destination would be appended - using ``remote_repo`` and ``test_repo_path`` - """ - self.alias = alias - self.test_repo_path = test_repo_path - self.remote_repo = remote_repo - self.clone_cmd = clone_cmd - - def setup(self): - if not os.path.isdir(self.test_repo_path): - self.fetch_repo() - - def fetch_repo(self): - """ - Tries to fetch repository from remote path. - """ - remote = self.remote_repo - eprint("Fetching repository %s into %s" % (remote, self.test_repo_path)) - run_command(self.clone_cmd, '%s %s' % (remote, self.test_repo_path))