##// END OF EJS Templates
vcs: reduce sql queries used during pull/push operations.
marcink -
r2140:61a36530 default
parent child Browse files
Show More
@@ -31,6 +31,7 b' import warnings'
31 import functools
31 import functools
32
32
33 from pyramid.threadlocal import get_current_registry
33 from pyramid.threadlocal import get_current_registry
34 from zope.cachedescriptors.property import Lazy as LazyProperty
34
35
35 from rhodecode.authentication.interface import IAuthnPluginRegistry
36 from rhodecode.authentication.interface import IAuthnPluginRegistry
36 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
37 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
@@ -168,6 +169,11 b' class RhodeCodeAuthPluginBase(object):'
168 db_type = '{}.encrypted'.format(db_type)
169 db_type = '{}.encrypted'.format(db_type)
169 return db_type
170 return db_type
170
171
172 @LazyProperty
173 def plugin_settings(self):
174 settings = SettingsModel().get_all_settings()
175 return settings
176
171 def is_enabled(self):
177 def is_enabled(self):
172 """
178 """
173 Returns true if this plugin is enabled. An enabled plugin can be
179 Returns true if this plugin is enabled. An enabled plugin can be
@@ -206,9 +212,10 b' class RhodeCodeAuthPluginBase(object):'
206 """
212 """
207 Returns a plugin setting by name.
213 Returns a plugin setting by name.
208 """
214 """
209 full_name = self._get_setting_full_name(name)
215 full_name = 'rhodecode_{}'.format(self._get_setting_full_name(name))
210 db_setting = SettingsModel().get_setting_by_name(full_name)
216 plugin_settings = self.plugin_settings
211 return db_setting.app_settings_value if db_setting else default
217
218 return plugin_settings.get(full_name) or default
212
219
213 def create_or_update_setting(self, name, value):
220 def create_or_update_setting(self, name, value):
214 """
221 """
@@ -68,7 +68,7 b' class AuthenticationPluginRegistry(objec'
68 plugins = []
68 plugins = []
69
69
70 # Add all enabled and active plugins to the list. We iterate over the
70 # Add all enabled and active plugins to the list. We iterate over the
71 # auth_plugins setting from DB beacuse it also represents the ordering.
71 # auth_plugins setting from DB because it also represents the ordering.
72 enabled_plugins = SettingsModel().get_auth_plugins()
72 enabled_plugins = SettingsModel().get_auth_plugins()
73 for plugin_id in enabled_plugins:
73 for plugin_id in enabled_plugins:
74 plugin = self.get_plugin(plugin_id)
74 plugin = self.get_plugin(plugin_id)
@@ -45,7 +45,7 b' from rhodecode.lib.utils import ('
45 get_repo_slug, set_rhodecode_config, password_changed,
45 get_repo_slug, set_rhodecode_config, password_changed,
46 get_enabled_hook_classes)
46 get_enabled_hook_classes)
47 from rhodecode.lib.utils2 import (
47 from rhodecode.lib.utils2 import (
48 str2bool, safe_unicode, AttributeDict, safe_int, md5, aslist)
48 str2bool, safe_unicode, AttributeDict, safe_int, md5, aslist, safe_str)
49 from rhodecode.model import meta
49 from rhodecode.model import meta
50 from rhodecode.model.db import Repository, User, ChangesetComment
50 from rhodecode.model.db import Repository, User, ChangesetComment
51 from rhodecode.model.notification import NotificationModel
51 from rhodecode.model.notification import NotificationModel
@@ -252,6 +252,9 b' class BasicAuth(AuthBasicAuthenticator):'
252 log.exception('Failed to fetch response for code %s' % http_code)
252 log.exception('Failed to fetch response for code %s' % http_code)
253 return HTTPForbidden
253 return HTTPForbidden
254
254
255 def get_rc_realm(self):
256 return safe_str(self.registry.rhodecode_settings.get('rhodecode_realm'))
257
255 def build_authentication(self):
258 def build_authentication(self):
256 head = WWW_AUTHENTICATE.tuples('Basic realm="%s"' % self.realm)
259 head = WWW_AUTHENTICATE.tuples('Basic realm="%s"' % self.realm)
257 if self._rc_auth_http_code and not self.initial_call:
260 if self._rc_auth_http_code and not self.initial_call:
@@ -45,7 +45,7 b' from rhodecode.lib.hooks_daemon import p'
45 from rhodecode.lib.middleware import appenlight
45 from rhodecode.lib.middleware import appenlight
46 from rhodecode.lib.middleware.utils import scm_app_http
46 from rhodecode.lib.middleware.utils import scm_app_http
47 from rhodecode.lib.utils import (
47 from rhodecode.lib.utils import (
48 is_valid_repo, get_rhodecode_realm, get_rhodecode_base_path, SLUG_RE)
48 is_valid_repo, get_rhodecode_base_path, SLUG_RE)
49 from rhodecode.lib.utils2 import safe_str, fix_PATH, str2bool, safe_unicode
49 from rhodecode.lib.utils2 import safe_str, fix_PATH, str2bool, safe_unicode
50 from rhodecode.lib.vcs.conf import settings as vcs_settings
50 from rhodecode.lib.vcs.conf import settings as vcs_settings
51 from rhodecode.lib.vcs.backends import base
51 from rhodecode.lib.vcs.backends import base
@@ -53,7 +53,7 b' from rhodecode.model import meta'
53 from rhodecode.model.db import User, Repository, PullRequest
53 from rhodecode.model.db import User, Repository, PullRequest
54 from rhodecode.model.scm import ScmModel
54 from rhodecode.model.scm import ScmModel
55 from rhodecode.model.pull_request import PullRequestModel
55 from rhodecode.model.pull_request import PullRequestModel
56
56 from rhodecode.model.settings import SettingsModel
57
57
58 log = logging.getLogger(__name__)
58 log = logging.getLogger(__name__)
59
59
@@ -107,9 +107,9 b' class SimpleVCS(object):'
107 self.config = config
107 self.config = config
108 # re-populated by specialized middleware
108 # re-populated by specialized middleware
109 self.repo_vcs_config = base.Config()
109 self.repo_vcs_config = base.Config()
110
110 self.rhodecode_settings = SettingsModel().get_all_settings(cache=True)
111 # base path of repo locations
111 self.basepath = rhodecode.CONFIG['base_path']
112 self.basepath = get_rhodecode_base_path()
112 registry.rhodecode_settings = self.rhodecode_settings
113 # authenticate this VCS request using authfunc
113 # authenticate this VCS request using authfunc
114 auth_ret_code_detection = \
114 auth_ret_code_detection = \
115 str2bool(self.config.get('auth_ret_code_detection', False))
115 str2bool(self.config.get('auth_ret_code_detection', False))
@@ -381,7 +381,7 b' class SimpleVCS(object):'
381 # before inject the calling repo_name for special scope checks
381 # before inject the calling repo_name for special scope checks
382 self.authenticate.acl_repo_name = self.acl_repo_name
382 self.authenticate.acl_repo_name = self.acl_repo_name
383 if not username:
383 if not username:
384 self.authenticate.realm = get_rhodecode_realm()
384 self.authenticate.realm = self.authenticate.get_rc_realm()
385
385
386 try:
386 try:
387 result = self.authenticate(environ)
387 result = self.authenticate(environ)
@@ -73,10 +73,10 b' def get_environ(url, request_method):'
73 ('/info/lfs/info/lfs/objects/batch', 'pull', 'POST'),
73 ('/info/lfs/info/lfs/objects/batch', 'pull', 'POST'),
74
74
75 ])
75 ])
76 def test_get_action(url, expected_action, request_method, pylonsapp):
76 def test_get_action(url, expected_action, request_method, pylonsapp, request_stub):
77 app = simplegit.SimpleGit(application=None,
77 app = simplegit.SimpleGit(application=None,
78 config={'auth_ret_code': '', 'base_path': ''},
78 config={'auth_ret_code': '', 'base_path': ''},
79 registry=None)
79 registry=request_stub.registry)
80 assert expected_action == app._get_action(get_environ(url, request_method))
80 assert expected_action == app._get_action(get_environ(url, request_method))
81
81
82
82
@@ -102,19 +102,19 b' def test_get_action(url, expected_action'
102 ('/info/lfs/info/lfs/objects/batch', 'info/lfs', 'POST'),
102 ('/info/lfs/info/lfs/objects/batch', 'info/lfs', 'POST'),
103
103
104 ])
104 ])
105 def test_get_repository_name(url, expected_repo_name, request_method, pylonsapp):
105 def test_get_repository_name(url, expected_repo_name, request_method, pylonsapp, request_stub):
106 app = simplegit.SimpleGit(application=None,
106 app = simplegit.SimpleGit(application=None,
107 config={'auth_ret_code': '', 'base_path': ''},
107 config={'auth_ret_code': '', 'base_path': ''},
108 registry=None)
108 registry=request_stub.registry)
109 assert expected_repo_name == app._get_repository_name(
109 assert expected_repo_name == app._get_repository_name(
110 get_environ(url, request_method))
110 get_environ(url, request_method))
111
111
112
112
113 def test_get_config(pylonsapp, user_util):
113 def test_get_config(user_util, pylonsapp, request_stub):
114 repo = user_util.create_repo(repo_type='git')
114 repo = user_util.create_repo(repo_type='git')
115 app = simplegit.SimpleGit(application=None,
115 app = simplegit.SimpleGit(application=None,
116 config={'auth_ret_code': '', 'base_path': ''},
116 config={'auth_ret_code': '', 'base_path': ''},
117 registry=None)
117 registry=request_stub.registry)
118 extras = {'foo': 'FOO', 'bar': 'BAR'}
118 extras = {'foo': 'FOO', 'bar': 'BAR'}
119
119
120 # We copy the extras as the method below will change the contents.
120 # We copy the extras as the method below will change the contents.
@@ -130,13 +130,13 b' def test_get_config(pylonsapp, user_util'
130 assert git_config == expected_config
130 assert git_config == expected_config
131
131
132
132
133 def test_create_wsgi_app_uses_scm_app_from_simplevcs(pylonsapp):
133 def test_create_wsgi_app_uses_scm_app_from_simplevcs(pylonsapp, request_stub):
134 config = {
134 config = {
135 'auth_ret_code': '',
135 'auth_ret_code': '',
136 'base_path': '',
136 'base_path': '',
137 'vcs.scm_app_implementation':
137 'vcs.scm_app_implementation':
138 'rhodecode.tests.lib.middleware.mock_scm_app',
138 'rhodecode.tests.lib.middleware.mock_scm_app',
139 }
139 }
140 app = simplegit.SimpleGit(application=None, config=config, registry=None)
140 app = simplegit.SimpleGit(application=None, config=config, registry=request_stub.registry)
141 wsgi_app = app._create_wsgi_app('/tmp/test', 'test_repo', {})
141 wsgi_app = app._create_wsgi_app('/tmp/test', 'test_repo', {})
142 assert wsgi_app is mock_scm_app.mock_git_wsgi
142 assert wsgi_app is mock_scm_app.mock_git_wsgi
@@ -53,10 +53,10 b' def get_environ(url):'
53 # Edge case: not cmd argument
53 # Edge case: not cmd argument
54 ('/foo/bar?key=tip', 'pull'),
54 ('/foo/bar?key=tip', 'pull'),
55 ])
55 ])
56 def test_get_action(url, expected_action):
56 def test_get_action(url, expected_action, request_stub):
57 app = simplehg.SimpleHg(application=None,
57 app = simplehg.SimpleHg(application=None,
58 config={'auth_ret_code': '', 'base_path': ''},
58 config={'auth_ret_code': '', 'base_path': ''},
59 registry=None)
59 registry=request_stub.registry)
60 assert expected_action == app._get_action(get_environ(url))
60 assert expected_action == app._get_action(get_environ(url))
61
61
62
62
@@ -71,18 +71,18 b' def test_get_action(url, expected_action'
71 ('/foo/bar/?cmd=pushkey&key=tip', 'foo/bar'),
71 ('/foo/bar/?cmd=pushkey&key=tip', 'foo/bar'),
72 ('/foo/bar/baz/?cmd=listkeys&key=tip', 'foo/bar/baz'),
72 ('/foo/bar/baz/?cmd=listkeys&key=tip', 'foo/bar/baz'),
73 ])
73 ])
74 def test_get_repository_name(url, expected_repo_name):
74 def test_get_repository_name(url, expected_repo_name, request_stub):
75 app = simplehg.SimpleHg(application=None,
75 app = simplehg.SimpleHg(application=None,
76 config={'auth_ret_code': '', 'base_path': ''},
76 config={'auth_ret_code': '', 'base_path': ''},
77 registry=None)
77 registry=request_stub.registry)
78 assert expected_repo_name == app._get_repository_name(get_environ(url))
78 assert expected_repo_name == app._get_repository_name(get_environ(url))
79
79
80
80
81 def test_get_config(pylonsapp, user_util):
81 def test_get_config(user_util, pylonsapp, request_stub):
82 repo = user_util.create_repo(repo_type='git')
82 repo = user_util.create_repo(repo_type='git')
83 app = simplehg.SimpleHg(application=None,
83 app = simplehg.SimpleHg(application=None,
84 config={'auth_ret_code': '', 'base_path': ''},
84 config={'auth_ret_code': '', 'base_path': ''},
85 registry=None)
85 registry=request_stub.registry)
86 extras = [('foo', 'FOO', 'bar', 'BAR')]
86 extras = [('foo', 'FOO', 'bar', 'BAR')]
87
87
88 hg_config = app._create_config(extras, repo_name=repo.repo_name)
88 hg_config = app._create_config(extras, repo_name=repo.repo_name)
@@ -116,13 +116,14 b' def test_get_config(pylonsapp, user_util'
116 assert entry in hg_config
116 assert entry in hg_config
117
117
118
118
119 def test_create_wsgi_app_uses_scm_app_from_simplevcs():
119 def test_create_wsgi_app_uses_scm_app_from_simplevcs(request_stub):
120 config = {
120 config = {
121 'auth_ret_code': '',
121 'auth_ret_code': '',
122 'base_path': '',
122 'base_path': '',
123 'vcs.scm_app_implementation':
123 'vcs.scm_app_implementation':
124 'rhodecode.tests.lib.middleware.mock_scm_app',
124 'rhodecode.tests.lib.middleware.mock_scm_app',
125 }
125 }
126 app = simplehg.SimpleHg(application=None, config=config, registry=None)
126 app = simplehg.SimpleHg(
127 application=None, config=config, registry=request_stub.registry)
127 wsgi_app = app._create_wsgi_app('/tmp/test', 'test_repo', {})
128 wsgi_app = app._create_wsgi_app('/tmp/test', 'test_repo', {})
128 assert wsgi_app is mock_scm_app.mock_hg_wsgi
129 assert wsgi_app is mock_scm_app.mock_hg_wsgi
@@ -29,12 +29,12 b' from rhodecode.lib.middleware.simplesvn '
29
29
30 class TestSimpleSvn(object):
30 class TestSimpleSvn(object):
31 @pytest.fixture(autouse=True)
31 @pytest.fixture(autouse=True)
32 def simple_svn(self, pylonsapp):
32 def simple_svn(self, pylonsapp, request_stub):
33 self.app = SimpleSvn(
33 self.app = SimpleSvn(
34 application='None',
34 application='None',
35 config={'auth_ret_code': '',
35 config={'auth_ret_code': '',
36 'base_path': rhodecode.CONFIG['base_path']},
36 'base_path': rhodecode.CONFIG['base_path']},
37 registry=None)
37 registry=request_stub.registry)
38
38
39 def test_get_config(self):
39 def test_get_config(self):
40 extras = {'foo': 'FOO', 'bar': 'BAR'}
40 extras = {'foo': 'FOO', 'bar': 'BAR'}
@@ -23,6 +23,7 b' import base64'
23 import mock
23 import mock
24 import pytest
24 import pytest
25
25
26 from rhodecode.lib.utils2 import AttributeDict
26 from rhodecode.tests.utils import CustomTestApp
27 from rhodecode.tests.utils import CustomTestApp
27
28
28 from rhodecode.lib.caching_query import FromCache
29 from rhodecode.lib.caching_query import FromCache
@@ -73,12 +74,12 b' class StubVCSController(simplevcs.Simple'
73
74
74
75
75 @pytest.fixture
76 @pytest.fixture
76 def vcscontroller(pylonsapp, config_stub):
77 def vcscontroller(pylonsapp, config_stub, request_stub):
77 config_stub.testing_securitypolicy()
78 config_stub.testing_securitypolicy()
78 config_stub.include('rhodecode.authentication')
79 config_stub.include('rhodecode.authentication')
79
80
80 #set_anonymous_access(True)
81 controller = StubVCSController(
81 controller = StubVCSController(pylonsapp, pylonsapp.config, None)
82 pylonsapp, pylonsapp.config, request_stub.registry)
82 app = HttpsFixup(controller, pylonsapp.config)
83 app = HttpsFixup(controller, pylonsapp.config)
83 app = CustomTestApp(app)
84 app = CustomTestApp(app)
84
85
@@ -134,7 +135,8 b' class StubFailVCSController(simplevcs.Si'
134
135
135 @pytest.fixture(scope='module')
136 @pytest.fixture(scope='module')
136 def fail_controller(pylonsapp):
137 def fail_controller(pylonsapp):
137 controller = StubFailVCSController(pylonsapp, pylonsapp.config, None)
138 controller = StubFailVCSController(
139 pylonsapp, pylonsapp.config, pylonsapp.config)
138 controller = HttpsFixup(controller, pylonsapp.config)
140 controller = HttpsFixup(controller, pylonsapp.config)
139 controller = CustomTestApp(controller)
141 controller = CustomTestApp(controller)
140 return controller
142 return controller
@@ -150,16 +152,18 b' def test_provides_traceback_for_appenlig'
150 assert 'appenlight.__traceback' in response.request.environ
152 assert 'appenlight.__traceback' in response.request.environ
151
153
152
154
153 def test_provides_utils_scm_app_as_scm_app_by_default(pylonsapp):
155 def test_provides_utils_scm_app_as_scm_app_by_default(pylonsapp, request_stub):
154 controller = StubVCSController(pylonsapp, pylonsapp.config, None)
156 controller = StubVCSController(
157 pylonsapp, pylonsapp.config, request_stub.registry)
155 assert controller.scm_app is scm_app_http
158 assert controller.scm_app is scm_app_http
156
159
157
160
158 def test_allows_to_override_scm_app_via_config(pylonsapp):
161 def test_allows_to_override_scm_app_via_config(pylonsapp, request_stub):
159 config = pylonsapp.config.copy()
162 config = pylonsapp.config.copy()
160 config['vcs.scm_app_implementation'] = (
163 config['vcs.scm_app_implementation'] = (
161 'rhodecode.tests.lib.middleware.mock_scm_app')
164 'rhodecode.tests.lib.middleware.mock_scm_app')
162 controller = StubVCSController(pylonsapp, config, None)
165 controller = StubVCSController(
166 pylonsapp, config, request_stub.registry)
163 assert controller.scm_app is mock_scm_app
167 assert controller.scm_app is mock_scm_app
164
168
165
169
@@ -214,12 +218,14 b' class TestShadowRepoRegularExpression(ob'
214 @pytest.mark.backends('git', 'hg')
218 @pytest.mark.backends('git', 'hg')
215 class TestShadowRepoExposure(object):
219 class TestShadowRepoExposure(object):
216
220
217 def test_pull_on_shadow_repo_propagates_to_wsgi_app(self, pylonsapp):
221 def test_pull_on_shadow_repo_propagates_to_wsgi_app(
222 self, pylonsapp, request_stub):
218 """
223 """
219 Check that a pull action to a shadow repo is propagated to the
224 Check that a pull action to a shadow repo is propagated to the
220 underlying wsgi app.
225 underlying wsgi app.
221 """
226 """
222 controller = StubVCSController(pylonsapp, pylonsapp.config, None)
227 controller = StubVCSController(
228 pylonsapp, pylonsapp.config, request_stub.registry)
223 controller._check_ssl = mock.Mock()
229 controller._check_ssl = mock.Mock()
224 controller.is_shadow_repo = True
230 controller.is_shadow_repo = True
225 controller._action = 'pull'
231 controller._action = 'pull'
@@ -238,12 +244,13 b' class TestShadowRepoExposure(object):'
238 # Assert that we got the response from the wsgi app.
244 # Assert that we got the response from the wsgi app.
239 assert response_body == controller.stub_response_body
245 assert response_body == controller.stub_response_body
240
246
241 def test_pull_on_shadow_repo_that_is_missing(self, pylonsapp):
247 def test_pull_on_shadow_repo_that_is_missing(self, pylonsapp, request_stub):
242 """
248 """
243 Check that a pull action to a shadow repo is propagated to the
249 Check that a pull action to a shadow repo is propagated to the
244 underlying wsgi app.
250 underlying wsgi app.
245 """
251 """
246 controller = StubVCSController(pylonsapp, pylonsapp.config, None)
252 controller = StubVCSController(
253 pylonsapp, pylonsapp.config, request_stub.registry)
247 controller._check_ssl = mock.Mock()
254 controller._check_ssl = mock.Mock()
248 controller.is_shadow_repo = True
255 controller.is_shadow_repo = True
249 controller._action = 'pull'
256 controller._action = 'pull'
@@ -262,11 +269,12 b' class TestShadowRepoExposure(object):'
262 # Assert that we got the response from the wsgi app.
269 # Assert that we got the response from the wsgi app.
263 assert '404 Not Found' in response_body
270 assert '404 Not Found' in response_body
264
271
265 def test_push_on_shadow_repo_raises(self, pylonsapp):
272 def test_push_on_shadow_repo_raises(self, pylonsapp, request_stub):
266 """
273 """
267 Check that a push action to a shadow repo is aborted.
274 Check that a push action to a shadow repo is aborted.
268 """
275 """
269 controller = StubVCSController(pylonsapp, pylonsapp.config, None)
276 controller = StubVCSController(
277 pylonsapp, pylonsapp.config, request_stub.registry)
270 controller._check_ssl = mock.Mock()
278 controller._check_ssl = mock.Mock()
271 controller.is_shadow_repo = True
279 controller.is_shadow_repo = True
272 controller._action = 'push'
280 controller._action = 'push'
@@ -285,13 +293,14 b' class TestShadowRepoExposure(object):'
285 # Assert that a 406 error is returned.
293 # Assert that a 406 error is returned.
286 assert '406 Not Acceptable' in response_body
294 assert '406 Not Acceptable' in response_body
287
295
288 def test_set_repo_names_no_shadow(self, pylonsapp):
296 def test_set_repo_names_no_shadow(self, pylonsapp, request_stub):
289 """
297 """
290 Check that the set_repo_names method sets all names to the one returned
298 Check that the set_repo_names method sets all names to the one returned
291 by the _get_repository_name method on a request to a non shadow repo.
299 by the _get_repository_name method on a request to a non shadow repo.
292 """
300 """
293 environ_stub = {}
301 environ_stub = {}
294 controller = StubVCSController(pylonsapp, pylonsapp.config, None)
302 controller = StubVCSController(
303 pylonsapp, pylonsapp.config, request_stub.registry)
295 controller._name = 'RepoGroup/MyRepo'
304 controller._name = 'RepoGroup/MyRepo'
296 controller.set_repo_names(environ_stub)
305 controller.set_repo_names(environ_stub)
297 assert not controller.is_shadow_repo
306 assert not controller.is_shadow_repo
@@ -300,7 +309,8 b' class TestShadowRepoExposure(object):'
300 controller.vcs_repo_name ==
309 controller.vcs_repo_name ==
301 controller._get_repository_name(environ_stub))
310 controller._get_repository_name(environ_stub))
302
311
303 def test_set_repo_names_with_shadow(self, pylonsapp, pr_util, config_stub):
312 def test_set_repo_names_with_shadow(
313 self, pylonsapp, pr_util, config_stub, request_stub):
304 """
314 """
305 Check that the set_repo_names method sets correct names on a request
315 Check that the set_repo_names method sets correct names on a request
306 to a shadow repo.
316 to a shadow repo.
@@ -313,7 +323,8 b' class TestShadowRepoExposure(object):'
313 pr_id=pull_request.pull_request_id,
323 pr_id=pull_request.pull_request_id,
314 pr_segment=TestShadowRepoRegularExpression.pr_segment,
324 pr_segment=TestShadowRepoRegularExpression.pr_segment,
315 shadow_segment=TestShadowRepoRegularExpression.shadow_segment)
325 shadow_segment=TestShadowRepoRegularExpression.shadow_segment)
316 controller = StubVCSController(pylonsapp, pylonsapp.config, None)
326 controller = StubVCSController(
327 pylonsapp, pylonsapp.config, request_stub.registry)
317 controller._name = shadow_url
328 controller._name = shadow_url
318 controller.set_repo_names({})
329 controller.set_repo_names({})
319
330
@@ -329,7 +340,7 b' class TestShadowRepoExposure(object):'
329 assert controller.is_shadow_repo
340 assert controller.is_shadow_repo
330
341
331 def test_set_repo_names_with_shadow_but_missing_pr(
342 def test_set_repo_names_with_shadow_but_missing_pr(
332 self, pylonsapp, pr_util, config_stub):
343 self, pylonsapp, pr_util, config_stub, request_stub):
333 """
344 """
334 Checks that the set_repo_names method enforces matching target repos
345 Checks that the set_repo_names method enforces matching target repos
335 and pull request IDs.
346 and pull request IDs.
@@ -340,7 +351,8 b' class TestShadowRepoExposure(object):'
340 pr_id=999999999,
351 pr_id=999999999,
341 pr_segment=TestShadowRepoRegularExpression.pr_segment,
352 pr_segment=TestShadowRepoRegularExpression.pr_segment,
342 shadow_segment=TestShadowRepoRegularExpression.shadow_segment)
353 shadow_segment=TestShadowRepoRegularExpression.shadow_segment)
343 controller = StubVCSController(pylonsapp, pylonsapp.config, None)
354 controller = StubVCSController(
355 pylonsapp, pylonsapp.config, request_stub.registry)
344 controller._name = shadow_url
356 controller._name = shadow_url
345 controller.set_repo_names({})
357 controller.set_repo_names({})
346
358
@@ -416,7 +428,8 b' class TestGenerateVcsResponse(object):'
416 'vcs.hooks.protocol': 'http',
428 'vcs.hooks.protocol': 'http',
417 'vcs.hooks.direct_calls': False,
429 'vcs.hooks.direct_calls': False,
418 }
430 }
419 controller = StubVCSController(None, settings, None)
431 registry = AttributeDict()
432 controller = StubVCSController(None, settings, registry)
420 controller._invalidate_cache = mock.Mock()
433 controller._invalidate_cache = mock.Mock()
421 controller.stub_response_body = response_body
434 controller.stub_response_body = response_body
422 self.start_response = mock.Mock()
435 self.start_response = mock.Mock()
@@ -465,11 +478,11 b' class TestInitializeGenerator(object):'
465
478
466
479
467 class TestPrepareHooksDaemon(object):
480 class TestPrepareHooksDaemon(object):
468 def test_calls_imported_prepare_callback_daemon(self, app_settings):
481 def test_calls_imported_prepare_callback_daemon(self, app_settings, request_stub):
469 expected_extras = {'extra1': 'value1'}
482 expected_extras = {'extra1': 'value1'}
470 daemon = DummyHooksCallbackDaemon()
483 daemon = DummyHooksCallbackDaemon()
471
484
472 controller = StubVCSController(None, app_settings, None)
485 controller = StubVCSController(None, app_settings, request_stub.registry)
473 prepare_patcher = mock.patch.object(
486 prepare_patcher = mock.patch.object(
474 simplevcs, 'prepare_callback_daemon',
487 simplevcs, 'prepare_callback_daemon',
475 return_value=(daemon, expected_extras))
488 return_value=(daemon, expected_extras))
General Comments 0
You need to be logged in to leave comments. Login now