Changeset - ff287676b206
[Not reviewed]
default
0 3 0
Anton Schur - 9 years ago 2017-04-26 10:21:56
tonich.sh@gmail.com
tests: initial_repo_scan = false in test.ini, explicitly do repo scan in the pytest configure phase.
3 files changed with 12 insertions and 13 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/conftest.py
Show inline comments
 
@@ -5,16 +5,18 @@ import pkg_resources
 

	
 
from paste.deploy import loadwsgi
 
from routes.util import URLGenerator
 

	
 
import pytest
 
from kallithea.controllers.root import RootController
 
from kallithea.lib.utils import repo2db_mapper
 
from kallithea.model.user import UserModel
 
from kallithea.model.meta import Session
 
from kallithea.model.db import Setting, User, UserIpMap
 
from kallithea.tests.base import invalidate_all_caches, TEST_USER_REGULAR_LOGIN
 
from kallithea.model.scm import ScmModel
 
from kallithea.tests.base import invalidate_all_caches, TEST_USER_REGULAR_LOGIN, TESTS_TMP_PATH
 
import kallithea.tests.base # FIXME: needed for setting testapp instance!!!
 

	
 
from tg.util.webtest import test_context
 

	
 
def pytest_configure():
 
    path = os.getcwd()
 
@@ -23,29 +25,30 @@ def pytest_configure():
 

	
 
    # Disable INFO logging of test database creation, restore with NOTSET
 
    logging.disable(logging.INFO)
 

	
 
    context = loadwsgi.loadcontext(loadwsgi.APP, 'config:kallithea/tests/test.ini', relative_to=path)
 

	
 
    test_env = not int(os.environ.get('KALLITHEA_NO_TMP_PATH', 0))
 
    test_index = not int(os.environ.get('KALLITHEA_WHOOSH_TEST_DISABLE', 0))
 
    if os.environ.get('TEST_DB'):
 
        # swap config if we pass environment variable
 
        context.local_conf['sqlalchemy.url'] = os.environ.get('TEST_DB')
 

	
 
    from kallithea.tests.fixture import create_test_env, create_test_index
 
    from kallithea.tests.base import TESTS_TMP_PATH
 
    # set KALLITHEA_NO_TMP_PATH=1 to disable re-creating the database and
 
    # test repos
 
    if test_env:
 

	
 
    # set KALLITHEA_NO_TMP_PATH=1 to disable re-creating the database and test repos
 
    if not int(os.environ.get('KALLITHEA_NO_TMP_PATH', 0)):
 
        create_test_env(TESTS_TMP_PATH, context.config())
 

	
 
    # set KALLITHEA_WHOOSH_TEST_DISABLE=1 to disable whoosh index during tests
 
    if test_index:
 
    if not int(os.environ.get('KALLITHEA_WHOOSH_TEST_DISABLE', 0)):
 
        create_test_index(TESTS_TMP_PATH, context.config(), True)
 

	
 
    kallithea.tests.base.testapp = context.create()
 
    # do initial repo scan
 
    repo2db_mapper(ScmModel().repo_scan(TESTS_TMP_PATH))
 

	
 
    logging.disable(logging.NOTSET)
 

	
 
    kallithea.tests.base.url = URLGenerator(RootController().mapper, kallithea.tests.base.environ)
 

	
 

	
 
@pytest.fixture
kallithea/tests/test.ini
Show inline comments
 
################################################################################
 
################################################################################
 
# Kallithea - config for tests:                                                #
 
# initial_repo_scan = true                                                     #
 
# sqlalchemy and kallithea_test.sqlite                                         #
 
# custom logging                                                               #
 
#                                                                              #
 
# The %(here)s variable will be replaced with the parent directory of this file#
 
################################################################################
 
################################################################################
 
@@ -185,14 +184,13 @@ lang =
 
cache_dir = %(here)s/../../data/test/cache
 
#index_dir = %(here)s/data/index
 
index_dir = %(here)s/../../data/test/index
 

	
 
## perform a full repository scan on each server start, this should be
 
## set to false after first startup, to allow faster server restarts.
 
#initial_repo_scan = false
 
initial_repo_scan = true
 
initial_repo_scan = false
 

	
 
## uncomment and set this path to use archive download cache
 
#archive_cache_dir = %(here)s/tarballcache
 
archive_cache_dir = %(here)s/../../data/test/tarballcache
 

	
 
## change this to unique ID for security
scripts/generate-ini.py
Show inline comments
 
@@ -27,24 +27,22 @@ mako_variable_values = {
 

	
 
# files to be generated from the mako template
 
ini_files = [
 
    ('kallithea/tests/test.ini',
 
        '''
 
        Kallithea - config for tests:
 
        initial_repo_scan = true
 
        sqlalchemy and kallithea_test.sqlite
 
        custom logging
 

	
 
        The %(here)s variable will be replaced with the parent directory of this file
 
        ''',
 
        {
 
            '[server:main]': {
 
                'port': '4999',
 
            },
 
            '[app:main]': {
 
                'initial_repo_scan': 'true',
 
                'app_instance_uuid': 'test',
 
                'show_revision_number': 'true',
 
                'beaker.cache.sql_cache_short.expire': '1',
 
                'beaker.session.secret': '{74e0cd75-b339-478b-b129-07dd221def1f}',
 
                'cache_dir': '%(here)s/../../data/test/cache',
 
                'index_dir': '%(here)s/../../data/test/index',
0 comments (0 inline, 0 general)