diff --git a/rhodecode/integrations/views.py b/rhodecode/integrations/views.py --- a/rhodecode/integrations/views.py +++ b/rhodecode/integrations/views.py @@ -40,7 +40,7 @@ from rhodecode.admin.navigation import n from rhodecode.translation import _ from rhodecode.integrations import integration_type_registry from rhodecode.model.validation_schema.schemas.integration_schema import ( - make_integration_schema) + make_integration_schema, IntegrationScopeType) log = logging.getLogger(__name__) @@ -151,7 +151,11 @@ class IntegrationSettingsViewBase(object defaults['options'] = { 'name': self.integration.name, 'enabled': self.integration.enabled, - 'scope': self.integration.scope, + 'scope': { + 'repo': self.integration.repo, + 'repo_group': self.integration.repo_group, + 'child_repos_only': self.integration.child_repos_only, + }, } else: if self.repo: @@ -168,10 +172,10 @@ class IntegrationSettingsViewBase(object 'name': _('{name} integration').format( name=self.IntegrationType.display_name), } - if self.repo: - defaults['options']['scope'] = self.repo - elif self.repo_group: - defaults['options']['scope'] = self.repo_group + defaults['options']['scope'] = { + 'repo': self.repo, + 'repo_group': self.repo_group, + } return defaults @@ -250,11 +254,10 @@ class IntegrationSettingsViewBase(object # scope is read only field in these cases, and has to be added options = pstruct.setdefault('options', {}) if 'scope' not in options: - if self.repo: - options['scope'] = 'repo:{}'.format(self.repo.repo_name) - elif self.repo_group: - options['scope'] = 'repogroup:{}'.format( - self.repo_group.group_name) + options['scope'] = IntegrationScopeType().serialize(None, { + 'repo': self.repo, + 'repo_group': self.repo_group, + }) try: valid_data = form.validate_pstruct(pstruct) @@ -276,7 +279,11 @@ class IntegrationSettingsViewBase(object name=valid_data['options']['name'], enabled=valid_data['options']['enabled'], settings=valid_data['settings'], - scope=scope) + repo=scope['repo'], + repo_group=scope['repo_group'], + child_repos_only=scope['child_repos_only'], + ) + self.integration.settings = valid_data['settings'] Session().commit() @@ -291,16 +298,16 @@ class IntegrationSettingsViewBase(object # keeping in mind if the original view was for /repo/ or /_admin/ admin_view = not (self.repo or self.repo_group) - if isinstance(self.integration.scope, Repository) and not admin_view: + if self.integration.repo and not admin_view: redirect_to = self.request.route_path( 'repo_integrations_edit', - repo_name=self.integration.scope.repo_name, + repo_name=self.integration.repo.repo_name, integration=self.integration.integration_type, integration_id=self.integration.integration_id) - elif isinstance(self.integration.scope, RepoGroup) and not admin_view: + elif self.integration.repo_group and not admin_view: redirect_to = self.request.route_path( 'repo_group_integrations_edit', - repo_group_name=self.integration.scope.group_name, + repo_group_name=self.integration.repo_group.group_name, integration=self.integration.integration_type, integration_id=self.integration.integration_id) else: diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -3499,36 +3499,18 @@ class Integration(Base, BaseModel): nullable=True, unique=None, default=None) repo_group = relationship('RepoGroup', lazy='joined') - @hybrid_property + @property def scope(self): if self.repo: - return self.repo + return repr(self.repo) if self.repo_group: - return self.repo_group + if self.child_repos_only: + return repr(self.repo_group) + ' (child repos only)' + else: + return repr(self.repo_group) + ' (recursive)' if self.child_repos_only: return 'root_repos' return 'global' - @scope.setter - def scope(self, value): - self.repo = None - self.repo_id = None - self.repo_group_id = None - self.repo_group = None - self.child_repos_only = False - if isinstance(value, Repository): - self.repo_id = value.repo_id - self.repo = value - elif isinstance(value, RepoGroup): - self.repo_group_id = value.group_id - self.repo_group = value - elif value == 'root_repos': - self.child_repos_only = True - elif value == 'global': - pass - else: - raise Exception("invalid scope: %s, must be one of " - "['global', 'root_repos', . ]" % value) - def __repr__(self): return '' % (self.integration_type, self.scope) diff --git a/rhodecode/model/integration.py b/rhodecode/model/integration.py --- a/rhodecode/model/integration.py +++ b/rhodecode/model/integration.py @@ -61,23 +61,24 @@ class IntegrationModel(BaseModel): raise Exception('integration must be int, long or Instance' ' of Integration got %s' % type(integration)) - def create(self, IntegrationType, name, enabled, scope, settings): + def create(self, IntegrationType, name, enabled, repo, repo_group, + child_repos_only, settings): """ Create an IntegrationType integration """ integration = Integration() integration.integration_type = IntegrationType.key self.sa.add(integration) - self.update_integration(integration, name, enabled, scope, settings) + self.update_integration(integration, name, enabled, repo, repo_group, + child_repos_only, settings) self.sa.commit() return integration - def update_integration(self, integration, name, enabled, scope, settings): - """ - :param scope: one of ['global', 'root_repos', . ] - """ - + def update_integration(self, integration, name, enabled, repo, repo_group, + child_repos_only, settings): integration = self.__get_integration(integration) - integration.scope = scope + integration.repo = repo + integration.repo_group = repo_group + integration.child_repos_only = child_repos_only integration.name = name integration.enabled = enabled integration.settings = settings @@ -127,7 +128,7 @@ class IntegrationModel(BaseModel): query = self.sa.query(Integration).filter( and_(Integration.repo_id==None, Integration.repo_group_id==None) ) - elif scope == 'root_repos': + elif scope == 'root-repos': query = self.sa.query(Integration).filter( and_(Integration.repo_id==None, Integration.repo_group_id==None, @@ -185,13 +186,21 @@ class IntegrationModel(BaseModel): if event.repo.group: clauses.append( - Integration.repo_group_id == event.repo.group.group_id + and_( + Integration.repo_group_id==event.repo.group.group_id, + Integration.child_repos_only==True + ) ) - # repo group cascade to kids (maybe implement this sometime?) - # clauses.append(Integration.repo_group_id.in_( - # [group.group_id for group in - # event.repo.groups_with_parents] - # )) + # repo group cascade to kids + clauses.append( + and_( + Integration.repo_group_id.in_( + [group.group_id for group in + event.repo.groups_with_parents] + ), + Integration.child_repos_only==False + ) + ) if not event.repo.group: # root repo diff --git a/rhodecode/model/validation_schema/schemas/integration_schema.py b/rhodecode/model/validation_schema/schemas/integration_schema.py --- a/rhodecode/model/validation_schema/schemas/integration_schema.py +++ b/rhodecode/model/validation_schema/schemas/integration_schema.py @@ -37,7 +37,7 @@ def integration_scope_choices(permission if 'hg.admin' in permissions['global']: result.extend([ ('global', _('Global (all repositories)')), - ('root_repos', _('Top level repositories only')), + ('root-repos', _('Top level repositories only')), ]) repo_choices = [ @@ -47,13 +47,19 @@ def integration_scope_choices(permission if repo_perm == 'repository.admin' ] repogroup_choices = [ - ('repogroup:%s' % repo_group_name, '/' + repo_group_name + ' (group)') + ('repogroup:%s' % repo_group_name, '/' + repo_group_name + '/ (child repos only)') + for repo_group_name, repo_group_perm + in permissions['repositories_groups'].items() + if repo_group_perm == 'group.admin' + ] + repogroup_recursive_choices = [ + ('repogroup-recursive:%s' % repo_group_name, '/' + repo_group_name + '/ (recursive)') for repo_group_name, repo_group_perm in permissions['repositories_groups'].items() if repo_group_perm == 'group.admin' ] result.extend( - sorted(repogroup_choices + repo_choices, + sorted(repogroup_recursive_choices + repogroup_choices + repo_choices, key=lambda (choice, label): choice.split(':', 1)[1] ) ) @@ -66,27 +72,24 @@ def deferred_integration_scopes_validato def _scope_validator(_node, scope): is_super_admin = 'hg.admin' in perms['global'] - if scope in ('global', 'root_repos'): + if scope.get('repo'): + if (is_super_admin or perms['repositories'].get( + scope['repo'].repo_name) == 'repository.admin'): + return True + msg = _('Only repo admins can create integrations') + raise colander.Invalid(_node, msg) + elif scope.get('repo_group'): + if (is_super_admin or perms['repositories_groups'].get( + scope['repo_group'].group_name) == 'group.admin'): + return True + + msg = _('Only repogroup admins can create integrations') + raise colander.Invalid(_node, msg) + else: if is_super_admin: return True msg = _('Only superadmins can create global integrations') raise colander.Invalid(_node, msg) - elif isinstance(scope, Repository): - if (is_super_admin or perms['repositories'].get( - scope.repo_name) == 'repository.admin'): - return True - msg = _('Only repo admins can create integrations') - raise colander.Invalid(_node, msg) - elif isinstance(scope, RepoGroup): - if (is_super_admin or perms['repositories_groups'].get( - scope.group_name) == 'group.admin'): - return True - - msg = _('Only repogroup admins can create integrations') - raise colander.Invalid(_node, msg) - - msg = _('Invalid integration scope: %s' % scope) - raise colander.Invalid(node, msg) return _scope_validator @@ -100,17 +103,26 @@ def deferred_integration_scopes_widget(n widget = deform.widget.Select2Widget(values=choices) return widget -class IntegrationScope(colander.SchemaType): + +class IntegrationScopeType(colander.SchemaType): def serialize(self, node, appstruct): if appstruct is colander.null: return colander.null - if isinstance(appstruct, Repository): - return 'repo:%s' % appstruct.repo_name - elif isinstance(appstruct, RepoGroup): - return 'repogroup:%s' % appstruct.group_name - elif appstruct in ('global', 'root_repos'): - return appstruct + if appstruct.get('repo'): + return 'repo:%s' % appstruct['repo'].repo_name + elif appstruct.get('repo_group'): + if appstruct.get('child_repos_only'): + return 'repogroup:%s' % appstruct['repo_group'].group_name + else: + return 'repogroup-recursive:%s' % ( + appstruct['repo_group'].group_name) + else: + if appstruct.get('child_repos_only'): + return 'root-repos' + else: + return 'global' + raise colander.Invalid(node, '%r is not a valid scope' % appstruct) def deserialize(self, node, cstruct): @@ -120,16 +132,43 @@ class IntegrationScope(colander.SchemaTy if cstruct.startswith('repo:'): repo = Repository.get_by_repo_name(cstruct.split(':')[1]) if repo: - return repo + return { + 'repo': repo, + 'repo_group': None, + 'child_repos_only': None, + } + elif cstruct.startswith('repogroup-recursive:'): + repo_group = RepoGroup.get_by_group_name(cstruct.split(':')[1]) + if repo_group: + return { + 'repo': None, + 'repo_group': repo_group, + 'child_repos_only': False + } elif cstruct.startswith('repogroup:'): repo_group = RepoGroup.get_by_group_name(cstruct.split(':')[1]) if repo_group: - return repo_group - elif cstruct in ('global', 'root_repos'): - return cstruct + return { + 'repo': None, + 'repo_group': repo_group, + 'child_repos_only': True + } + elif cstruct == 'global': + return { + 'repo': None, + 'repo_group': None, + 'child_repos_only': False + } + elif cstruct == 'root-repos': + return { + 'repo': None, + 'repo_group': None, + 'child_repos_only': True + } raise colander.Invalid(node, '%r is not a valid scope' % cstruct) + class IntegrationOptionsSchemaBase(colander.MappingSchema): name = colander.SchemaNode( @@ -140,10 +179,10 @@ class IntegrationOptionsSchemaBase(colan ) scope = colander.SchemaNode( - IntegrationScope(), + IntegrationScopeType(), description=_( - 'Scope of the integration. Group scope means the integration ' - ' runs on all child repos of that group.'), + 'Scope of the integration. Recursive means the integration ' + ' runs on all repos of that group and children recursively.'), title=_('Integration scope'), validator=deferred_integration_scopes_validator, widget=deferred_integration_scopes_widget, diff --git a/rhodecode/templates/admin/integrations/list.html b/rhodecode/templates/admin/integrations/list.html --- a/rhodecode/templates/admin/integrations/list.html +++ b/rhodecode/templates/admin/integrations/list.html @@ -166,14 +166,17 @@ %elif integration.repo_group: ${_('repogroup')}:${integration.repo_group.group_name} + %if integration.child_repos_only: + ${_('child repos only')} + %else: + ${_('cascade to all')} + %endif %else: - %if integration.scope == 'root_repos': + %if integration.child_repos_only: ${_('top level repos only')} - %elif integration.scope == 'global': + %else: ${_('global')} - %else: - ${_('unknown scope')}: ${integration.scope} %endif %endif diff --git a/rhodecode/tests/functional/test_integrations.py b/rhodecode/tests/functional/test_integrations.py --- a/rhodecode/tests/functional/test_integrations.py +++ b/rhodecode/tests/functional/test_integrations.py @@ -222,12 +222,14 @@ def _post_integration_test_helper(app, u scopes_destinations = [ ('global', ADMIN_PREFIX + '/integrations'), - ('root_repos', + ('root-repos', ADMIN_PREFIX + '/integrations'), ('repo:%s' % repo.repo_name, '/%s/settings/integrations' % repo.repo_name), ('repogroup:%s' % repo_group.group_name, '/%s/settings/integrations' % repo_group.group_name), + ('repogroup-recursive:%s' % repo_group.group_name, + '/%s/settings/integrations' % repo_group.group_name), ] for scope, destination in scopes_destinations: diff --git a/rhodecode/tests/integrations/test_integration.py b/rhodecode/tests/integrations/test_integration.py --- a/rhodecode/tests/integrations/test_integration.py +++ b/rhodecode/tests/integrations/test_integration.py @@ -51,75 +51,84 @@ class TestDeleteScopesDeletesIntegration def integration_repos(request, StubIntegrationType, stub_integration_settings): """ Create repositories and integrations for testing, and destroy them after + + Structure: + root_repo + parent_group/ + parent_repo + child_group/ + child_repo + other_group/ + other_repo """ fixture = Fixture() - repo_group_1_id = 'int_test_repo_group_1_%s' % time.time() - repo_group_1 = fixture.create_repo_group(repo_group_1_id) - repo_group_2_id = 'int_test_repo_group_2_%s' % time.time() - repo_group_2 = fixture.create_repo_group(repo_group_2_id) + + parent_group_id = 'int_test_parent_group_%s' % time.time() + parent_group = fixture.create_repo_group(parent_group_id) + + other_group_id = 'int_test_other_group_%s' % time.time() + other_group = fixture.create_repo_group(other_group_id) - repo_1_id = 'int_test_repo_1_%s' % time.time() - repo_1 = fixture.create_repo(repo_1_id, repo_group=repo_group_1) - repo_2_id = 'int_test_repo_2_%s' % time.time() - repo_2 = fixture.create_repo(repo_2_id, repo_group=repo_group_2) + child_group_id = ( + parent_group_id + '/' + 'int_test_child_group_%s' % time.time()) + child_group = fixture.create_repo_group(child_group_id) + + parent_repo_id = 'int_test_parent_repo_%s' % time.time() + parent_repo = fixture.create_repo(parent_repo_id, repo_group=parent_group) + + child_repo_id = 'int_test_child_repo_%s' % time.time() + child_repo = fixture.create_repo(child_repo_id, repo_group=child_group) + + other_repo_id = 'int_test_other_repo_%s' % time.time() + other_repo = fixture.create_repo(other_repo_id, repo_group=other_group) root_repo_id = 'int_test_repo_root_%s' % time.time() root_repo = fixture.create_repo(root_repo_id) - integration_global = IntegrationModel().create( - StubIntegrationType, settings=stub_integration_settings, - enabled=True, name='test global integration', scope='global') - integration_root_repos = IntegrationModel().create( - StubIntegrationType, settings=stub_integration_settings, - enabled=True, name='test root repos integration', scope='root_repos') - integration_repo_1 = IntegrationModel().create( - StubIntegrationType, settings=stub_integration_settings, - enabled=True, name='test repo 1 integration', scope=repo_1) - integration_repo_group_1 = IntegrationModel().create( - StubIntegrationType, settings=stub_integration_settings, - enabled=True, name='test repo group 1 integration', scope=repo_group_1) - integration_repo_2 = IntegrationModel().create( - StubIntegrationType, settings=stub_integration_settings, - enabled=True, name='test repo 2 integration', scope=repo_2) - integration_repo_group_2 = IntegrationModel().create( - StubIntegrationType, settings=stub_integration_settings, - enabled=True, name='test repo group 2 integration', scope=repo_group_2) + integrations = {} + for name, repo, repo_group, child_repos_only in [ + ('global', None, None, None), + ('root_repos', None, None, True), + ('parent_repo', parent_repo, None, None), + ('child_repo', child_repo, None, None), + ('other_repo', other_repo, None, None), + ('root_repo', root_repo, None, None), + ('parent_group', None, parent_group, True), + ('parent_group_recursive', None, parent_group, False), + ('child_group', None, child_group, True), + ('child_group_recursive', None, child_group, False), + ('other_group', None, other_group, True), + ('other_group_recursive', None, other_group, False), + ]: + integrations[name] = IntegrationModel().create( + StubIntegrationType, settings=stub_integration_settings, + enabled=True, name='test %s integration' % name, + repo=repo, repo_group=repo_group, child_repos_only=child_repos_only) Session().commit() def _cleanup(): - Session().delete(integration_global) - Session().delete(integration_root_repos) - Session().delete(integration_repo_1) - Session().delete(integration_repo_group_1) - Session().delete(integration_repo_2) - Session().delete(integration_repo_group_2) + for integration in integrations.values(): + Session.delete(integration) + fixture.destroy_repo(root_repo) - fixture.destroy_repo(repo_1) - fixture.destroy_repo(repo_2) - fixture.destroy_repo_group(repo_group_1) - fixture.destroy_repo_group(repo_group_2) + fixture.destroy_repo(child_repo) + fixture.destroy_repo(parent_repo) + fixture.destroy_repo(other_repo) + fixture.destroy_repo_group(child_group) + fixture.destroy_repo_group(parent_group) + fixture.destroy_repo_group(other_group) request.addfinalizer(_cleanup) return { + 'integrations': integrations, 'repos': { - 'repo_1': repo_1, - 'repo_2': repo_2, 'root_repo': root_repo, - }, - 'repo_groups': { - 'repo_group_1': repo_group_1, - 'repo_group_2': repo_group_2, - }, - 'integrations': { - 'global': integration_global, - 'root_repos': integration_root_repos, - 'repo_1': integration_repo_1, - 'repo_2': integration_repo_2, - 'repo_group_1': integration_repo_group_1, - 'repo_group_2': integration_repo_group_2, + 'other_repo': other_repo, + 'parent_repo': parent_repo, + 'child_repo': child_repo, } } @@ -133,27 +142,41 @@ def test_enabled_integration_repo_scopes assert triggered_integrations == [ integrations['global'], - integrations['root_repos'] + integrations['root_repos'], + integrations['root_repo'], + ] + + + triggered_integrations = IntegrationModel().get_for_event( + events.RepoEvent(repos['other_repo'])) + + assert triggered_integrations == [ + integrations['global'], + integrations['other_repo'], + integrations['other_group'], + integrations['other_group_recursive'], ] triggered_integrations = IntegrationModel().get_for_event( - events.RepoEvent(repos['repo_1'])) + events.RepoEvent(repos['parent_repo'])) assert triggered_integrations == [ integrations['global'], - integrations['repo_1'], - integrations['repo_group_1'] + integrations['parent_repo'], + integrations['parent_group'], + integrations['parent_group_recursive'], ] - triggered_integrations = IntegrationModel().get_for_event( - events.RepoEvent(repos['repo_2'])) + events.RepoEvent(repos['child_repo'])) assert triggered_integrations == [ integrations['global'], - integrations['repo_2'], - integrations['repo_group_2'], + integrations['child_repo'], + integrations['parent_group_recursive'], + integrations['child_group'], + integrations['child_group_recursive'], ] @@ -172,17 +195,24 @@ def test_disabled_integration_repo_scope triggered_integrations = IntegrationModel().get_for_event( - events.RepoEvent(repos['repo_1'])) + events.RepoEvent(repos['parent_repo'])) assert triggered_integrations == [] triggered_integrations = IntegrationModel().get_for_event( - events.RepoEvent(repos['repo_2'])) + events.RepoEvent(repos['child_repo'])) assert triggered_integrations == [] + triggered_integrations = IntegrationModel().get_for_event( + events.RepoEvent(repos['other_repo'])) + + assert triggered_integrations == [] + + + def test_enabled_non_repo_integrations(integration_repos): integrations = integration_repos['integrations'] diff --git a/rhodecode/tests/models/schemas/test_integration_schema.py b/rhodecode/tests/models/schemas/test_integration_schema.py --- a/rhodecode/tests/models/schemas/test_integration_schema.py +++ b/rhodecode/tests/models/schemas/test_integration_schema.py @@ -47,42 +47,93 @@ class TestIntegrationSchema(object): 'repositories_groups': {}, } - perms_tests = { - ('repo:%s' % repo.repo_name, repo): [ - ({}, False), - ({'global': ['hg.admin']}, True), - ({'global': []}, False), - ({'repositories': {repo.repo_name: 'repository.admin'}}, True), - ({'repositories': {repo.repo_name: 'repository.read'}}, False), - ({'repositories': {repo.repo_name: 'repository.write'}}, False), - ({'repositories': {repo.repo_name: 'repository.none'}}, False), - ], - ('repogroup:%s' % repo_group.group_name, repo_group): [ - ({}, False), - ({'global': ['hg.admin']}, True), - ({'global': []}, False), - ({'repositories_groups': - {repo_group.group_name: 'group.admin'}}, True), - ({'repositories_groups': - {repo_group.group_name: 'group.read'}}, False), - ({'repositories_groups': - {repo_group.group_name: 'group.write'}}, False), - ({'repositories_groups': - {repo_group.group_name: 'group.none'}}, False), - ], - ('global', 'global'): [ - ({}, False), - ({'global': ['hg.admin']}, True), - ({'global': []}, False), - ], - ('root_repos', 'root_repos'): [ - ({}, False), - ({'global': ['hg.admin']}, True), - ({'global': []}, False), - ], - } + perms_tests = [ + ( + 'repo:%s' % repo.repo_name, + { + 'child_repos_only': None, + 'repo_group': None, + 'repo': repo, + }, + [ + ({}, False), + ({'global': ['hg.admin']}, True), + ({'global': []}, False), + ({'repositories': {repo.repo_name: 'repository.admin'}}, True), + ({'repositories': {repo.repo_name: 'repository.read'}}, False), + ({'repositories': {repo.repo_name: 'repository.write'}}, False), + ({'repositories': {repo.repo_name: 'repository.none'}}, False), + ] + ), + ( + 'repogroup:%s' % repo_group.group_name, + { + 'repo': None, + 'repo_group': repo_group, + 'child_repos_only': True, + }, + [ + ({}, False), + ({'global': ['hg.admin']}, True), + ({'global': []}, False), + ({'repositories_groups': + {repo_group.group_name: 'group.admin'}}, True), + ({'repositories_groups': + {repo_group.group_name: 'group.read'}}, False), + ({'repositories_groups': + {repo_group.group_name: 'group.write'}}, False), + ({'repositories_groups': + {repo_group.group_name: 'group.none'}}, False), + ] + ), + ( + 'repogroup-recursive:%s' % repo_group.group_name, + { + 'repo': None, + 'repo_group': repo_group, + 'child_repos_only': False, + }, + [ + ({}, False), + ({'global': ['hg.admin']}, True), + ({'global': []}, False), + ({'repositories_groups': + {repo_group.group_name: 'group.admin'}}, True), + ({'repositories_groups': + {repo_group.group_name: 'group.read'}}, False), + ({'repositories_groups': + {repo_group.group_name: 'group.write'}}, False), + ({'repositories_groups': + {repo_group.group_name: 'group.none'}}, False), + ] + ), + ( + 'global', + { + 'repo': None, + 'repo_group': None, + 'child_repos_only': False, + }, [ + ({}, False), + ({'global': ['hg.admin']}, True), + ({'global': []}, False), + ] + ), + ( + 'root-repos', + { + 'repo': None, + 'repo_group': None, + 'child_repos_only': True, + }, [ + ({}, False), + ({'global': ['hg.admin']}, True), + ({'global': []}, False), + ] + ), + ] - for (scope_input, scope_output), perms_allowed in perms_tests.items(): + for scope_input, scope_output, perms_allowed in perms_tests: for perms_update, allowed in perms_allowed: perms = dict(empty_perms_dict, **perms_update) diff --git a/rhodecode/tests/plugin.py b/rhodecode/tests/plugin.py --- a/rhodecode/tests/plugin.py +++ b/rhodecode/tests/plugin.py @@ -1709,7 +1709,8 @@ def repo_integration_stub(request, repo_ stub_integration_settings): integration = IntegrationModel().create( StubIntegrationType, settings=stub_integration_settings, enabled=True, - name='test repo integration', scope=repo_stub) + name='test repo integration', + repo=repo_stub, repo_group=None, child_repos_only=None) @request.addfinalizer def cleanup(): @@ -1723,7 +1724,23 @@ def repogroup_integration_stub(request, stub_integration_settings): integration = IntegrationModel().create( StubIntegrationType, settings=stub_integration_settings, enabled=True, - name='test repogroup integration', scope=test_repo_group) + name='test repogroup integration', + repo=None, repo_group=test_repo_group, child_repos_only=True) + + @request.addfinalizer + def cleanup(): + IntegrationModel().delete(integration) + + return integration + + +@pytest.fixture +def repogroup_recursive_integration_stub(request, test_repo_group, + StubIntegrationType, stub_integration_settings): + integration = IntegrationModel().create( + StubIntegrationType, settings=stub_integration_settings, enabled=True, + name='test recursive repogroup integration', + repo=None, repo_group=test_repo_group, child_repos_only=False) @request.addfinalizer def cleanup(): @@ -1737,7 +1754,8 @@ def global_integration_stub(request, Stu stub_integration_settings): integration = IntegrationModel().create( StubIntegrationType, settings=stub_integration_settings, enabled=True, - name='test global integration', scope='global') + name='test global integration', + repo=None, repo_group=None, child_repos_only=None) @request.addfinalizer def cleanup(): @@ -1751,7 +1769,8 @@ def root_repos_integration_stub(request, stub_integration_settings): integration = IntegrationModel().create( StubIntegrationType, settings=stub_integration_settings, enabled=True, - name='test global integration', scope='root_repos') + name='test global integration', + repo=None, repo_group=None, child_repos_only=True) @request.addfinalizer def cleanup():