changeset 6622:ff287676b206

tests: initial_repo_scan = false in test.ini, explicitly do repo scan in the pytest configure phase.
author Anton Schur <tonich.sh@gmail.com>
date Wed, 26 Apr 2017 11:21:56 +0300
parents 6cc40e545e9a
children 5b3568c99cc3
files kallithea/tests/conftest.py kallithea/tests/test.ini scripts/generate-ini.py
diffstat 3 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/tests/conftest.py	Wed Apr 26 11:29:30 2017 +0300
+++ b/kallithea/tests/conftest.py	Wed Apr 26 11:21:56 2017 +0300
@@ -8,10 +8,12 @@
 
 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
@@ -26,23 +28,24 @@
 
     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)
--- a/kallithea/tests/test.ini	Wed Apr 26 11:29:30 2017 +0300
+++ b/kallithea/tests/test.ini	Wed Apr 26 11:21:56 2017 +0300
@@ -1,7 +1,6 @@
 ################################################################################
 ################################################################################
 # Kallithea - config for tests:                                                #
-# initial_repo_scan = true                                                     #
 # sqlalchemy and kallithea_test.sqlite                                         #
 # custom logging                                                               #
 #                                                                              #
@@ -188,8 +187,7 @@
 
 ## 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
--- a/scripts/generate-ini.py	Wed Apr 26 11:29:30 2017 +0300
+++ b/scripts/generate-ini.py	Wed Apr 26 11:21:56 2017 +0300
@@ -30,7 +30,6 @@
     ('kallithea/tests/test.ini',
         '''
         Kallithea - config for tests:
-        initial_repo_scan = true
         sqlalchemy and kallithea_test.sqlite
         custom logging
 
@@ -41,7 +40,6 @@
                 'port': '4999',
             },
             '[app:main]': {
-                'initial_repo_scan': 'true',
                 'app_instance_uuid': 'test',
                 'show_revision_number': 'true',
                 'beaker.cache.sql_cache_short.expire': '1',