Show More
@@ -150,25 +150,6 b' def setup_configuration(app):' | |||
|
150 | 150 | |
|
151 | 151 | load_rcextensions(root_path=config['here']) |
|
152 | 152 | |
|
153 | # FIXME move test setup code out of here | |
|
154 | test = os.path.split(config['__file__'])[-1] == 'test.ini' | |
|
155 | if test: | |
|
156 | test_env = not int(os.environ.get('KALLITHEA_NO_TMP_PATH', 0)) | |
|
157 | test_index = not int(os.environ.get('KALLITHEA_WHOOSH_TEST_DISABLE', 0)) | |
|
158 | if os.environ.get('TEST_DB'): | |
|
159 | # swap config if we pass environment variable | |
|
160 | config['sqlalchemy.url'] = os.environ.get('TEST_DB') | |
|
161 | ||
|
162 | from kallithea.tests.fixture import create_test_env, create_test_index | |
|
163 | from kallithea.tests.base import TESTS_TMP_PATH | |
|
164 | #set KALLITHEA_NO_TMP_PATH=1 to disable re-creating the database and | |
|
165 | #test repos | |
|
166 | if test_env: | |
|
167 | create_test_env(TESTS_TMP_PATH, config) | |
|
168 | #set KALLITHEA_WHOOSH_TEST_DISABLE=1 to disable whoosh index during tests | |
|
169 | if test_index: | |
|
170 | create_test_index(TESTS_TMP_PATH, config, True) | |
|
171 | ||
|
172 | 153 | set_available_permissions(config) |
|
173 | 154 | repos_path = make_ui('db').configitems('paths')[0][1] |
|
174 | 155 | config['base_path'] = repos_path |
@@ -3,9 +3,8 b' import sys' | |||
|
3 | 3 | import logging |
|
4 | 4 | import pkg_resources |
|
5 | 5 | |
|
6 |
from paste.deploy import load |
|
|
6 | from paste.deploy import loadwsgi | |
|
7 | 7 | from routes.util import URLGenerator |
|
8 | from tg import config | |
|
9 | 8 | |
|
10 | 9 | import pytest |
|
11 | 10 | from kallithea.controllers.root import RootController |
@@ -24,7 +23,26 b' def pytest_configure():' | |||
|
24 | 23 | |
|
25 | 24 | # Disable INFO logging of test database creation, restore with NOTSET |
|
26 | 25 | logging.disable(logging.INFO) |
|
27 | kallithea.tests.base.testapp = loadapp('config:kallithea/tests/test.ini', relative_to=path) | |
|
26 | ||
|
27 | context = loadwsgi.loadcontext(loadwsgi.APP, 'config:kallithea/tests/test.ini', relative_to=path) | |
|
28 | ||
|
29 | test_env = not int(os.environ.get('KALLITHEA_NO_TMP_PATH', 0)) | |
|
30 | test_index = not int(os.environ.get('KALLITHEA_WHOOSH_TEST_DISABLE', 0)) | |
|
31 | if os.environ.get('TEST_DB'): | |
|
32 | # swap config if we pass environment variable | |
|
33 | context.local_conf['sqlalchemy.url'] = os.environ.get('TEST_DB') | |
|
34 | ||
|
35 | from kallithea.tests.fixture import create_test_env, create_test_index | |
|
36 | from kallithea.tests.base import TESTS_TMP_PATH | |
|
37 | # set KALLITHEA_NO_TMP_PATH=1 to disable re-creating the database and | |
|
38 | # test repos | |
|
39 | if test_env: | |
|
40 | create_test_env(TESTS_TMP_PATH, context.config()) | |
|
41 | # set KALLITHEA_WHOOSH_TEST_DISABLE=1 to disable whoosh index during tests | |
|
42 | if test_index: | |
|
43 | create_test_index(TESTS_TMP_PATH, context.config(), True) | |
|
44 | ||
|
45 | kallithea.tests.base.testapp = context.create() | |
|
28 | 46 | logging.disable(logging.NOTSET) |
|
29 | 47 | |
|
30 | 48 | kallithea.tests.base.url = URLGenerator(RootController().mapper, kallithea.tests.base.environ) |
@@ -342,8 +342,8 b' def create_test_env(repos_test_path, con' | |||
|
342 | 342 | # PART TWO make test repo |
|
343 | 343 | log.debug('making test vcs repositories') |
|
344 | 344 | |
|
345 |
idx_path = config[' |
|
|
346 |
data_path = config[' |
|
|
345 | idx_path = config['index_dir'] | |
|
346 | data_path = config['cache_dir'] | |
|
347 | 347 | |
|
348 | 348 | #clean index and data |
|
349 | 349 | if idx_path and os.path.exists(idx_path): |
@@ -376,7 +376,7 b' def create_test_index(repo_location, con' | |||
|
376 | 376 | from kallithea.lib.indexers.daemon import WhooshIndexingDaemon |
|
377 | 377 | from kallithea.lib.pidlock import DaemonLock, LockHeld |
|
378 | 378 | |
|
379 |
index_location = os.path.join(config[' |
|
|
379 | index_location = os.path.join(config['index_dir']) | |
|
380 | 380 | if not os.path.exists(index_location): |
|
381 | 381 | os.makedirs(index_location) |
|
382 | 382 |
General Comments 0
You need to be logged in to leave comments.
Login now