diff --git a/rhodecode/apps/repository/tests/__init__.py b/rhodecode/apps/repository/tests/__init__.py new file mode 100644 diff --git a/rhodecode/apps/repository/tests/test_repo_settings.py b/rhodecode/apps/repository/tests/test_repo_settings.py new file mode 100644 --- /dev/null +++ b/rhodecode/apps/repository/tests/test_repo_settings.py @@ -0,0 +1,230 @@ +# -*- coding: utf-8 -*- + +# Copyright (C) 2010-2017 RhodeCode GmbH +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License, version 3 +# (only), as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# This program is dual-licensed. If you wish to learn more about the +# RhodeCode Enterprise Edition, including its added features, Support services, +# and proprietary license terms, please see https://rhodecode.com/licenses/ + +import mock +import pytest + +from rhodecode.lib.utils2 import str2bool +from rhodecode.lib.vcs.exceptions import RepositoryRequirementError +from rhodecode.model.db import Repository, UserRepoToPerm, Permission, User +from rhodecode.model.meta import Session +from rhodecode.tests import ( + url, HG_REPO, TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_LOGIN, + assert_session_flash) +from rhodecode.tests.fixture import Fixture + +fixture = Fixture() + + +def route_path(name, params=None, **kwargs): + import urllib + + base_url = { + 'edit_repo': '/{repo_name}/settings', + }[name].format(**kwargs) + + if params: + base_url = '{}?{}'.format(base_url, urllib.urlencode(params)) + return base_url + + +def _get_permission_for_user(user, repo): + perm = UserRepoToPerm.query()\ + .filter(UserRepoToPerm.repository == + Repository.get_by_repo_name(repo))\ + .filter(UserRepoToPerm.user == User.get_by_username(user))\ + .all() + return perm + + +@pytest.mark.usefixtures('autologin_user', 'app') +class TestAdminRepoSettings(object): + @pytest.mark.parametrize('urlname', [ + 'edit_repo', + ]) + def test_show_page(self, urlname, app, backend): + app.get(route_path(urlname, repo_name=backend.repo_name), status=200) + + def test_edit_accessible_when_missing_requirements( + self, backend_hg, autologin_user): + scm_patcher = mock.patch.object( + Repository, 'scm_instance', side_effect=RepositoryRequirementError) + with scm_patcher: + self.app.get(route_path('edit_repo', repo_name=backend_hg.repo_name)) + + @pytest.mark.parametrize('urlname', [ + 'edit_repo_perms', + 'edit_repo_advanced', + 'repo_vcs_settings', + 'edit_repo_fields', + 'repo_settings_issuetracker', + 'edit_repo_caches', + 'edit_repo_remote', + 'edit_repo_statistics', + ]) + def test_show_page_pylons(self, urlname, app): + app.get(url(urlname, repo_name=HG_REPO)) + + @pytest.mark.parametrize('update_settings', [ + {'repo_description': 'alter-desc'}, + {'repo_owner': TEST_USER_REGULAR_LOGIN}, + {'repo_private': 'true'}, + {'repo_enable_locking': 'true'}, + {'repo_enable_downloads': 'true'}, + ]) + def test_update_repo_settings(self, update_settings, csrf_token, backend, user_util): + repo = user_util.create_repo(repo_type=backend.alias) + repo_name = repo.repo_name + + params = fixture._get_repo_create_params( + csrf_token=csrf_token, + repo_name=repo_name, + repo_type=backend.alias, + repo_owner=TEST_USER_ADMIN_LOGIN, + repo_description='DESC', + + repo_private='false', + repo_enable_locking='false', + repo_enable_downloads='false') + params.update(update_settings) + self.app.post( + route_path('edit_repo', repo_name=repo_name), + params=params, status=302) + + repo = Repository.get_by_repo_name(repo_name) + assert repo.user.username == \ + update_settings.get('repo_owner', repo.user.username) + + assert repo.description == \ + update_settings.get('repo_description', repo.description) + + assert repo.private == \ + str2bool(update_settings.get( + 'repo_private', repo.private)) + + assert repo.enable_locking == \ + str2bool(update_settings.get( + 'repo_enable_locking', repo.enable_locking)) + + assert repo.enable_downloads == \ + str2bool(update_settings.get( + 'repo_enable_downloads', repo.enable_downloads)) + + def test_update_repo_name_via_settings(self, csrf_token, user_util, backend): + repo = user_util.create_repo(repo_type=backend.alias) + repo_name = repo.repo_name + + repo_group = user_util.create_repo_group() + repo_group_name = repo_group.group_name + new_name = repo_group_name + '_' + repo_name + + params = fixture._get_repo_create_params( + csrf_token=csrf_token, + repo_name=new_name, + repo_type=backend.alias, + repo_owner=TEST_USER_ADMIN_LOGIN, + repo_description='DESC', + repo_private='false', + repo_enable_locking='false', + repo_enable_downloads='false') + self.app.post( + route_path('edit_repo', repo_name=repo_name), + params=params, status=302) + repo = Repository.get_by_repo_name(new_name) + assert repo.repo_name == new_name + + def test_update_repo_group_via_settings(self, csrf_token, user_util, backend): + repo = user_util.create_repo(repo_type=backend.alias) + repo_name = repo.repo_name + + repo_group = user_util.create_repo_group() + repo_group_name = repo_group.group_name + repo_group_id = repo_group.group_id + + new_name = repo_group_name + '/' + repo_name + params = fixture._get_repo_create_params( + csrf_token=csrf_token, + repo_name=repo_name, + repo_type=backend.alias, + repo_owner=TEST_USER_ADMIN_LOGIN, + repo_description='DESC', + repo_group=repo_group_id, + repo_private='false', + repo_enable_locking='false', + repo_enable_downloads='false') + self.app.post( + route_path('edit_repo', repo_name=repo_name), + params=params, status=302) + repo = Repository.get_by_repo_name(new_name) + assert repo.repo_name == new_name + + def test_set_private_flag_sets_default_user_permissions_to_none( + self, autologin_user, backend, csrf_token): + + # initially repository perm should be read + perm = _get_permission_for_user(user='default', repo=backend.repo_name) + assert len(perm) == 1 + assert perm[0].permission.permission_name == 'repository.read' + assert not backend.repo.private + + response = self.app.post( + route_path('edit_repo', repo_name=backend.repo_name), + params=fixture._get_repo_create_params( + repo_private='true', + repo_name=backend.repo_name, + repo_type=backend.alias, + repo_owner=TEST_USER_ADMIN_LOGIN, + csrf_token=csrf_token), status=302) + + assert_session_flash( + response, + msg='Repository %s updated successfully' % (backend.repo_name)) + + repo = Repository.get_by_repo_name(backend.repo_name) + assert repo.private is True + + # now the repo default permission should be None + perm = _get_permission_for_user(user='default', repo=backend.repo_name) + assert len(perm) == 1 + assert perm[0].permission.permission_name == 'repository.none' + + response = self.app.post( + route_path('edit_repo', repo_name=backend.repo_name), + params=fixture._get_repo_create_params( + repo_private='false', + repo_name=backend.repo_name, + repo_type=backend.alias, + repo_owner=TEST_USER_ADMIN_LOGIN, + csrf_token=csrf_token), status=302) + + assert_session_flash( + response, + msg='Repository %s updated successfully' % (backend.repo_name)) + assert backend.repo.private is False + + # we turn off private now the repo default permission should stay None + perm = _get_permission_for_user(user='default', repo=backend.repo_name) + assert len(perm) == 1 + assert perm[0].permission.permission_name == 'repository.none' + + # update this permission back + perm[0].permission = Permission.get_by_key('repository.read') + Session().add(perm[0]) + Session().commit() diff --git a/rhodecode/apps/repository/tests/test_vcs_settings.py b/rhodecode/apps/repository/tests/test_vcs_settings.py new file mode 100644 --- /dev/null +++ b/rhodecode/apps/repository/tests/test_vcs_settings.py @@ -0,0 +1,117 @@ +# -*- coding: utf-8 -*- + +# Copyright (C) 2010-2017 RhodeCode GmbH +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License, version 3 +# (only), as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# This program is dual-licensed. If you wish to learn more about the +# RhodeCode Enterprise Edition, including its added features, Support services, +# and proprietary license terms, please see https://rhodecode.com/licenses/ + +import mock +import pytest + +import rhodecode +from rhodecode.model.settings import SettingsModel +from rhodecode.tests import url +from rhodecode.tests.utils import AssertResponse + + +def route_path(name, params=None, **kwargs): + import urllib + + base_url = { + 'edit_repo': '/{repo_name}/settings', + }[name].format(**kwargs) + + if params: + base_url = '{}?{}'.format(base_url, urllib.urlencode(params)) + return base_url + + +@pytest.mark.usefixtures('autologin_user', 'app') +class TestAdminRepoVcsSettings(object): + + @pytest.mark.parametrize('setting_name, setting_backends', [ + ('hg_use_rebase_for_merging', ['hg']), + ]) + def test_labs_settings_visible_if_enabled( + self, setting_name, setting_backends, backend): + if backend.alias not in setting_backends: + pytest.skip('Setting not available for backend {}'.format(backend)) + + vcs_settings_url = url( + 'repo_vcs_settings', repo_name=backend.repo.repo_name) + + with mock.patch.dict( + rhodecode.CONFIG, {'labs_settings_active': 'true'}): + response = self.app.get(vcs_settings_url) + + assertr = AssertResponse(response) + assertr.one_element_exists('#rhodecode_{}'.format(setting_name)) + + @pytest.mark.parametrize('setting_name, setting_backends', [ + ('hg_use_rebase_for_merging', ['hg']), + ]) + def test_labs_settings_not_visible_if_disabled( + self, setting_name, setting_backends, backend): + if backend.alias not in setting_backends: + pytest.skip('Setting not available for backend {}'.format(backend)) + + vcs_settings_url = url( + 'repo_vcs_settings', repo_name=backend.repo.repo_name) + + with mock.patch.dict( + rhodecode.CONFIG, {'labs_settings_active': 'false'}): + response = self.app.get(vcs_settings_url) + + assertr = AssertResponse(response) + assertr.no_element_exists('#rhodecode_{}'.format(setting_name)) + + @pytest.mark.parametrize('setting_name, setting_backends', [ + ('hg_use_rebase_for_merging', ['hg']), + ]) + def test_update_boolean_settings( + self, csrf_token, setting_name, setting_backends, backend): + if backend.alias not in setting_backends: + pytest.skip('Setting not available for backend {}'.format(backend)) + + repo = backend.create_repo() + + settings_model = SettingsModel(repo=repo) + vcs_settings_url = url( + 'repo_vcs_settings', repo_name=repo.repo_name) + + self.app.post( + vcs_settings_url, + params={ + 'inherit_global_settings': False, + 'new_svn_branch': 'dummy-value-for-testing', + 'new_svn_tag': 'dummy-value-for-testing', + 'rhodecode_{}'.format(setting_name): 'true', + 'csrf_token': csrf_token, + }) + setting = settings_model.get_setting_by_name(setting_name) + assert setting.app_settings_value + + self.app.post( + vcs_settings_url, + params={ + 'inherit_global_settings': False, + 'new_svn_branch': 'dummy-value-for-testing', + 'new_svn_tag': 'dummy-value-for-testing', + 'rhodecode_{}'.format(setting_name): 'false', + 'csrf_token': csrf_token, + }) + setting = settings_model.get_setting_by_name(setting_name) + assert not setting.app_settings_value diff --git a/rhodecode/tests/config/test_sanitize_settings.py b/rhodecode/tests/config/test_sanitize_settings.py --- a/rhodecode/tests/config/test_sanitize_settings.py +++ b/rhodecode/tests/config/test_sanitize_settings.py @@ -21,6 +21,7 @@ import pytest +from rhodecode.tests import no_newline_id_generator from rhodecode.config.middleware import ( _sanitize_vcs_settings, _bool_setting, _string_setting, _list_setting, _int_setting) @@ -70,7 +71,7 @@ class TestHelperFunctions(object): (' hg\n git\n svn ', ['hg', 'git', 'svn']), (', hg , git , svn , ', ['', 'hg', 'git', 'svn', '']), ('cheese,free node,other', ['cheese', 'free node', 'other']), - ]) + ], ids=no_newline_id_generator) def test_list_setting_helper(self, raw, expected): key = 'dummy-key' settings = {key: raw} diff --git a/rhodecode/tests/controllers/test_repo_groups.py b/rhodecode/tests/controllers/test_repo_groups.py --- a/rhodecode/tests/controllers/test_repo_groups.py +++ b/rhodecode/tests/controllers/test_repo_groups.py @@ -64,7 +64,7 @@ def test_repo_groups_load_defaults( personal_group = personal_group_with_parent controller._RepoGroupsController__load_defaults(True, personal_group) - expected_list = ['-1', personal_group.parent_group.group_id] + expected_list = [-1, personal_group.parent_group.group_id] returned_group_ids = [group[0] for group in c.repo_groups] assert returned_group_ids == expected_list @@ -74,6 +74,6 @@ def test_repo_groups_load_defaults_with_ personal_group = personal_group_with_parent controller._RepoGroupsController__load_defaults(True) - expected_list = sorted(['-1', personal_group.group_id]) + expected_list = sorted([-1, personal_group.group_id]) returned_group_ids = sorted([group[0] for group in c.repo_groups]) assert returned_group_ids == expected_list diff --git a/rhodecode/tests/functional/test_admin_repo_settings.py b/rhodecode/tests/functional/test_admin_repo_settings.py deleted file mode 100644 --- a/rhodecode/tests/functional/test_admin_repo_settings.py +++ /dev/null @@ -1,118 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (C) 2010-2017 RhodeCode GmbH -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License, version 3 -# (only), as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# This program is dual-licensed. If you wish to learn more about the -# RhodeCode Enterprise Edition, including its added features, Support services, -# and proprietary license terms, please see https://rhodecode.com/licenses/ - -import mock -import pytest - -import rhodecode -from rhodecode.model.settings import SettingsModel -from rhodecode.tests import url, HG_REPO -from rhodecode.tests.utils import AssertResponse - - -@pytest.mark.usefixtures('autologin_user', 'app') -class TestAdminRepoSettingsController: - @pytest.mark.parametrize('urlname', [ - 'edit_repo', - 'edit_repo_perms', - 'edit_repo_advanced', - 'repo_vcs_settings', - 'edit_repo_fields', - 'repo_settings_issuetracker', - 'edit_repo_caches', - 'edit_repo_remote', - 'edit_repo_statistics', - ]) - def test_simple_get(self, urlname, app): - app.get(url(urlname, repo_name=HG_REPO)) - - @pytest.mark.parametrize('setting_name, setting_backends', [ - ('hg_use_rebase_for_merging', ['hg']), - ]) - def test_labs_settings_visible_if_enabled( - self, setting_name, setting_backends, backend): - if backend.alias not in setting_backends: - pytest.skip('Setting not available for backend {}'.format(backend)) - - vcs_settings_url = url( - 'repo_vcs_settings', repo_name=backend.repo.repo_name) - - with mock.patch.dict( - rhodecode.CONFIG, {'labs_settings_active': 'true'}): - response = self.app.get(vcs_settings_url) - - assertr = AssertResponse(response) - assertr.one_element_exists('#rhodecode_{}'.format(setting_name)) - - @pytest.mark.parametrize('setting_name, setting_backends', [ - ('hg_use_rebase_for_merging', ['hg']), - ]) - def test_labs_settings_not_visible_if_disabled( - self, setting_name, setting_backends, backend): - if backend.alias not in setting_backends: - pytest.skip('Setting not available for backend {}'.format(backend)) - - vcs_settings_url = url( - 'repo_vcs_settings', repo_name=backend.repo.repo_name) - - with mock.patch.dict( - rhodecode.CONFIG, {'labs_settings_active': 'false'}): - response = self.app.get(vcs_settings_url) - - assertr = AssertResponse(response) - assertr.no_element_exists('#rhodecode_{}'.format(setting_name)) - - @pytest.mark.parametrize('setting_name, setting_backends', [ - ('hg_use_rebase_for_merging', ['hg']), - ]) - def test_update_boolean_settings( - self, csrf_token, setting_name, setting_backends, backend): - if backend.alias not in setting_backends: - pytest.skip('Setting not available for backend {}'.format(backend)) - - repo = backend.create_repo() - - settings_model = SettingsModel(repo=repo) - vcs_settings_url = url( - 'repo_vcs_settings', repo_name=repo.repo_name) - - self.app.post( - vcs_settings_url, - params={ - 'inherit_global_settings': False, - 'new_svn_branch': 'dummy-value-for-testing', - 'new_svn_tag': 'dummy-value-for-testing', - 'rhodecode_{}'.format(setting_name): 'true', - 'csrf_token': csrf_token, - }) - setting = settings_model.get_setting_by_name(setting_name) - assert setting.app_settings_value - - self.app.post( - vcs_settings_url, - params={ - 'inherit_global_settings': False, - 'new_svn_branch': 'dummy-value-for-testing', - 'new_svn_tag': 'dummy-value-for-testing', - 'rhodecode_{}'.format(setting_name): 'false', - 'csrf_token': csrf_token, - }) - setting = settings_model.get_setting_by_name(setting_name) - assert not setting.app_settings_value diff --git a/rhodecode/tests/functional/test_admin_repos.py b/rhodecode/tests/functional/test_admin_repos.py --- a/rhodecode/tests/functional/test_admin_repos.py +++ b/rhodecode/tests/functional/test_admin_repos.py @@ -400,67 +400,6 @@ class TestAdminRepos(object): def test_show(self, autologin_user, backend): self.app.get(url('repo', repo_name=backend.repo_name)) - def test_edit(self, backend, autologin_user): - self.app.get(url('edit_repo', repo_name=backend.repo_name)) - - def test_edit_accessible_when_missing_requirements( - self, backend_hg, autologin_user): - scm_patcher = mock.patch.object( - Repository, 'scm_instance', side_effect=RepositoryRequirementError) - with scm_patcher: - self.app.get(url('edit_repo', repo_name=backend_hg.repo_name)) - - def test_set_private_flag_sets_default_to_none( - self, autologin_user, backend, csrf_token): - # initially repository perm should be read - perm = _get_permission_for_user(user='default', repo=backend.repo_name) - assert len(perm) == 1 - assert perm[0].permission.permission_name == 'repository.read' - assert not backend.repo.private - - response = self.app.post( - url('repo', repo_name=backend.repo_name), - fixture._get_repo_create_params( - repo_private=1, - repo_name=backend.repo_name, - repo_type=backend.alias, - user=TEST_USER_ADMIN_LOGIN, - _method='put', - csrf_token=csrf_token)) - assert_session_flash( - response, - msg='Repository %s updated successfully' % (backend.repo_name)) - assert backend.repo.private - - # now the repo default permission should be None - perm = _get_permission_for_user(user='default', repo=backend.repo_name) - assert len(perm) == 1 - assert perm[0].permission.permission_name == 'repository.none' - - response = self.app.post( - url('repo', repo_name=backend.repo_name), - fixture._get_repo_create_params( - repo_private=False, - repo_name=backend.repo_name, - repo_type=backend.alias, - user=TEST_USER_ADMIN_LOGIN, - _method='put', - csrf_token=csrf_token)) - assert_session_flash( - response, - msg='Repository %s updated successfully' % (backend.repo_name)) - assert not backend.repo.private - - # we turn off private now the repo default permission should stay None - perm = _get_permission_for_user(user='default', repo=backend.repo_name) - assert len(perm) == 1 - assert perm[0].permission.permission_name == 'repository.none' - - # update this permission back - perm[0].permission = Permission.get_by_key('repository.read') - Session().add(perm[0]) - Session().commit() - def test_default_user_cannot_access_private_repo_in_a_group( self, autologin_user, user_util, backend, csrf_token): diff --git a/rhodecode/tests/models/schemas/test_repo_group_schema.py b/rhodecode/tests/models/schemas/test_repo_group_schema.py --- a/rhodecode/tests/models/schemas/test_repo_group_schema.py +++ b/rhodecode/tests/models/schemas/test_repo_group_schema.py @@ -52,18 +52,18 @@ class TestRepoGroupSchema(object): ) schema_data = schema.deserialize(dict( - repo_group_name='dupa', + repo_group_name='my_schema_group', repo_group_owner=user_admin.username )) - assert schema_data['repo_group_name'] == 'dupa' + assert schema_data['repo_group_name'] == u'my_schema_group' assert schema_data['repo_group'] == { 'repo_group_id': None, 'repo_group_name': types.RootLocation, - 'repo_group_name_without_group': 'dupa'} + 'repo_group_name_without_group': u'my_schema_group'} @pytest.mark.parametrize('given, err_key, expected_exc', [ - ('xxx/dupa', 'repo_group', 'Parent repository group `xxx` does not exist'), + ('xxx/my_schema_group', 'repo_group', 'Parent repository group `xxx` does not exist'), ('', 'repo_group_name', 'Name must start with a letter or number. Got ``'), ]) def test_deserialize_with_bad_group_name( @@ -86,7 +86,7 @@ class TestRepoGroupSchema(object): user=user_admin ) - full_name = test_repo_group.group_name + '/dupa' + full_name = test_repo_group.group_name + u'/my_schema_group' schema_data = schema.deserialize(dict( repo_group_name=full_name, repo_group_owner=user_admin.username @@ -96,7 +96,7 @@ class TestRepoGroupSchema(object): assert schema_data['repo_group'] == { 'repo_group_id': test_repo_group.group_id, 'repo_group_name': test_repo_group.group_name, - 'repo_group_name_without_group': 'dupa'} + 'repo_group_name_without_group': u'my_schema_group'} def test_deserialize_with_group_name_regular_user_no_perms( self, app, user_regular, test_repo_group): @@ -104,7 +104,7 @@ class TestRepoGroupSchema(object): user=user_regular ) - full_name = test_repo_group.group_name + '/dupa' + full_name = test_repo_group.group_name + u'/my_schema_group' with pytest.raises(colander.Invalid) as excinfo: schema.deserialize(dict( repo_group_name=full_name, diff --git a/rhodecode/tests/models/schemas/test_repo_schema.py b/rhodecode/tests/models/schemas/test_repo_schema.py --- a/rhodecode/tests/models/schemas/test_repo_schema.py +++ b/rhodecode/tests/models/schemas/test_repo_schema.py @@ -57,19 +57,20 @@ class TestRepoSchema(object): ) schema_data = schema.deserialize(dict( - repo_name='dupa', + repo_name='my_schema_repo', repo_type='hg', repo_owner=user_admin.username )) - assert schema_data['repo_name'] == 'dupa' + assert schema_data['repo_name'] == u'my_schema_repo' assert schema_data['repo_group'] == { 'repo_group_id': None, 'repo_group_name': types.RootLocation, - 'repo_name_without_group': 'dupa'} + 'repo_name_with_group': u'my_schema_repo', + 'repo_name_without_group': u'my_schema_repo'} @pytest.mark.parametrize('given, err_key, expected_exc', [ - ('xxx/dupa','repo_group', 'Repository group `xxx` does not exist'), + ('xxx/my_schema_repo','repo_group', 'Repository group `xxx` does not exist'), ('', 'repo_name', 'Name must start with a letter or number. Got ``'), ]) def test_deserialize_with_bad_group_name( @@ -95,7 +96,7 @@ class TestRepoSchema(object): user=user_admin ) - full_name = test_repo_group.group_name + '/dupa' + full_name = test_repo_group.group_name + u'/my_schema_repo' schema_data = schema.deserialize(dict( repo_name=full_name, repo_type='hg', @@ -106,7 +107,8 @@ class TestRepoSchema(object): assert schema_data['repo_group'] == { 'repo_group_id': test_repo_group.group_id, 'repo_group_name': test_repo_group.group_name, - 'repo_name_without_group': 'dupa'} + 'repo_name_with_group': full_name, + 'repo_name_without_group': u'my_schema_repo'} def test_deserialize_with_group_name_regular_user_no_perms( self, app, user_regular, test_repo_group): @@ -115,7 +117,7 @@ class TestRepoSchema(object): user=user_regular ) - full_name = test_repo_group.group_name + '/dupa' + full_name = test_repo_group.group_name + '/my_schema_repo' with pytest.raises(colander.Invalid) as excinfo: schema.deserialize(dict( repo_name=full_name, diff --git a/rhodecode/tests/models/test_scm.py b/rhodecode/tests/models/test_scm.py --- a/rhodecode/tests/models/test_scm.py +++ b/rhodecode/tests/models/test_scm.py @@ -27,6 +27,7 @@ from mock import Mock, patch, DEFAULT import rhodecode from rhodecode.model import db, scm +from rhodecode.tests import no_newline_id_generator def test_scm_instance_config(backend): @@ -295,7 +296,7 @@ class TestCheckRhodecodeHook(object): @pytest.mark.parametrize("file_content, expected_result", [ ("RC_HOOK_VER = '3.3.3'\n", True), ("RC_HOOK = '3.3.3'\n", False), - ]) + ], ids=no_newline_id_generator) @patch('os.path.exists', Mock(return_value=True)) def test_signatures(self, file_content, expected_result): hook_content_patcher = patch.object( diff --git a/rhodecode/tests/other/test_libs.py b/rhodecode/tests/other/test_libs.py --- a/rhodecode/tests/other/test_libs.py +++ b/rhodecode/tests/other/test_libs.py @@ -27,6 +27,8 @@ import datetime import string import mock import pytest + +from rhodecode.tests import no_newline_id_generator from rhodecode.tests.utils import run_test_concurrently from rhodecode.lib.helpers import InitialsGravatar @@ -113,7 +115,7 @@ def test_str2bool(str_bool, expected): (pref+"user.dot hej ! not-needed maril@domain.org", []), (pref+"\n@marcin", ['marcin']), ] -for pref in ['', '\n', 'hi !', '\t', '\n\n']])) +for pref in ['', '\n', 'hi !', '\t', '\n\n']]), ids=no_newline_id_generator) def test_mention_extractor(text, expected): from rhodecode.lib.utils2 import extract_mentioned_users got = extract_mentioned_users(text) @@ -378,7 +380,7 @@ def _quick_url(text, tmpl="""%s""", url_=url_)