Show More
@@ -112,18 +112,6 b' def load_environment(global_conf, app_co' | |||||
112 |
|
112 | |||
113 | # sets the c attribute access when don't existing attribute are accessed |
|
113 | # sets the c attribute access when don't existing attribute are accessed | |
114 | config['pylons.strict_tmpl_context'] = True |
|
114 | config['pylons.strict_tmpl_context'] = True | |
115 | config_file_name = os.path.split(config['__file__'])[-1] |
|
|||
116 | test = re.match('^test[\w_]*\.ini$', config_file_name) is not None |
|
|||
117 | if test: |
|
|||
118 | if test_env is None: |
|
|||
119 | test_env = not int(os.environ.get('RC_NO_TMP_PATH', 0)) |
|
|||
120 |
|
||||
121 | from rhodecode.lib.utils import create_test_env, create_test_index |
|
|||
122 | from rhodecode.tests import TESTS_TMP_PATH |
|
|||
123 | # test repos |
|
|||
124 | if test_env: |
|
|||
125 | create_test_env(TESTS_TMP_PATH, config) |
|
|||
126 | create_test_index(TESTS_TMP_PATH, config, True) |
|
|||
127 |
|
115 | |||
128 | # Limit backends to "vcs.backends" from configuration |
|
116 | # Limit backends to "vcs.backends" from configuration | |
129 | backends = config['vcs.backends'] = aslist( |
|
117 | backends = config['vcs.backends'] = aslist( |
@@ -157,14 +157,22 b' def make_pyramid_app(global_config, **se' | |||||
157 | # behavior in the old application. |
|
157 | # behavior in the old application. | |
158 | settings_pylons = settings.copy() |
|
158 | settings_pylons = settings.copy() | |
159 |
|
159 | |||
160 | # TODO: Remove this by refactoring the init DB function. |
|
160 | # Some parts of the code expect a merge of global and app settings. | |
161 | # Put debug flag into settings for DB setup. |
|
161 | settings_merged = global_config.copy() | |
162 | settings['debug'] = global_config.get('debug', False) |
|
162 | settings_merged.update(settings) | |
163 | utils.initialize_database(settings) |
|
|||
164 |
|
163 | |||
165 | sanitize_settings_and_apply_defaults(settings) |
|
164 | sanitize_settings_and_apply_defaults(settings) | |
166 | config = Configurator(settings=settings) |
|
165 | config = Configurator(settings=settings) | |
167 | add_pylons_compat_data(config.registry, global_config, settings_pylons) |
|
166 | add_pylons_compat_data(config.registry, global_config, settings_pylons) | |
|
167 | ||||
|
168 | # Initialize the database connection. | |||
|
169 | utils.initialize_database(settings_merged) | |||
|
170 | ||||
|
171 | # If this is a test run we prepare the test environment like | |||
|
172 | # creating a test database, test search index and test repositories. | |||
|
173 | if settings['is_test']: | |||
|
174 | utils.initialize_test_environment(settings_merged) | |||
|
175 | ||||
168 | includeme(config) |
|
176 | includeme(config) | |
169 | includeme_last(config) |
|
177 | includeme_last(config) | |
170 | pyramid_app = config.make_wsgi_app() |
|
178 | pyramid_app = config.make_wsgi_app() |
@@ -73,6 +73,18 b' def initialize_database(config):' | |||||
73 | init_model(engine, encryption_key=config['beaker.session.secret']) |
|
73 | init_model(engine, encryption_key=config['beaker.session.secret']) | |
74 |
|
74 | |||
75 |
|
75 | |||
|
76 | def initialize_test_environment(settings, test_env=None): | |||
|
77 | if test_env is None: | |||
|
78 | test_env = not int(os.environ.get('RC_NO_TMP_PATH', 0)) | |||
|
79 | ||||
|
80 | from rhodecode.lib.utils import create_test_env, create_test_index | |||
|
81 | from rhodecode.tests import TESTS_TMP_PATH | |||
|
82 | # test repos | |||
|
83 | if test_env: | |||
|
84 | create_test_env(TESTS_TMP_PATH, settings) | |||
|
85 | create_test_index(TESTS_TMP_PATH, settings, True) | |||
|
86 | ||||
|
87 | ||||
76 | def get_vcs_server_protocol(config): |
|
88 | def get_vcs_server_protocol(config): | |
77 | protocol = config.get('vcs.server.protocol', 'pyro4') |
|
89 | protocol = config.get('vcs.server.protocol', 'pyro4') | |
78 | return protocol |
|
90 | return protocol |
@@ -755,10 +755,10 b' def create_test_env(repos_test_path, con' | |||||
755 | # PART TWO make test repo |
|
755 | # PART TWO make test repo | |
756 | log.debug('making test vcs repositories') |
|
756 | log.debug('making test vcs repositories') | |
757 |
|
757 | |||
758 |
idx_path = config[' |
|
758 | idx_path = config['search.location'] | |
759 |
data_path = config[' |
|
759 | data_path = config['cache_dir'] | |
760 |
|
760 | |||
761 | #clean index and data |
|
761 | # clean index and data | |
762 | if idx_path and os.path.exists(idx_path): |
|
762 | if idx_path and os.path.exists(idx_path): | |
763 | log.debug('remove %s', idx_path) |
|
763 | log.debug('remove %s', idx_path) | |
764 | shutil.rmtree(idx_path) |
|
764 | shutil.rmtree(idx_path) | |
@@ -767,7 +767,7 b' def create_test_env(repos_test_path, con' | |||||
767 | log.debug('remove %s', data_path) |
|
767 | log.debug('remove %s', data_path) | |
768 | shutil.rmtree(data_path) |
|
768 | shutil.rmtree(data_path) | |
769 |
|
769 | |||
770 | #CREATE DEFAULT TEST REPOS |
|
770 | # CREATE DEFAULT TEST REPOS | |
771 | cur_dir = dn(dn(abspath(__file__))) |
|
771 | cur_dir = dn(dn(abspath(__file__))) | |
772 | with tarfile.open(jn(cur_dir, 'tests', 'fixtures', |
|
772 | with tarfile.open(jn(cur_dir, 'tests', 'fixtures', | |
773 | 'vcs_test_hg.tar.gz')) as tar: |
|
773 | 'vcs_test_hg.tar.gz')) as tar: | |
@@ -787,7 +787,6 b' def create_test_env(repos_test_path, con' | |||||
787 | tar.extractall(jn(TESTS_TMP_PATH, SVN_REPO)) |
|
787 | tar.extractall(jn(TESTS_TMP_PATH, SVN_REPO)) | |
788 |
|
788 | |||
789 |
|
789 | |||
790 |
|
||||
791 | #============================================================================== |
|
790 | #============================================================================== | |
792 | # PASTER COMMANDS |
|
791 | # PASTER COMMANDS | |
793 | #============================================================================== |
|
792 | #============================================================================== |
General Comments 0
You need to be logged in to leave comments.
Login now