test_vcs_operations_rcextensions_push.py
81 lines
| 3.1 KiB
| text/x-python
|
PythonLexer
r5607 | # Copyright (C) 2010-2023 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 <http://www.gnu.org/licenses/>. | ||||
# | ||||
# 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 os | ||||
import pytest | ||||
from rhodecode.tests.fixtures.rcextensions_fixtures import store_rcextensions | ||||
from rhodecode.tests.vcs_operations import ( | ||||
Command, _check_proper_hg_push, _check_proper_git_push, | ||||
_add_files_and_push) | ||||
@pytest.mark.usefixtures( | ||||
"init_pyramid_app", | ||||
"repo_group_repos", | ||||
"disable_anonymous_user", | ||||
"disable_locking", | ||||
) | ||||
class TestVCSOperationsWithRCExtensions(object): | ||||
def test_push_when_rcextensions_fail_hg(self, rcstack, tmpdir, user_util, rcextensions, rcextensions_modification): | ||||
repo = user_util.create_repo(repo_type='hg') | ||||
clone_url = rcstack.repo_clone_url(repo.repo_name) | ||||
Command(os.path.dirname(tmpdir.strpath)).execute( | ||||
'hg clone', clone_url, tmpdir.strpath) | ||||
stdout, stderr = _add_files_and_push( | ||||
'hg', tmpdir.strpath, clone_url=clone_url) | ||||
_check_proper_hg_push(stdout, stderr) | ||||
mods = [ | ||||
('_pre_push_hook', | ||||
""" | ||||
return HookResponse(1, 'HOOK_FAIL_TEST_HG') | ||||
""") | ||||
] | ||||
rcstack_location = os.path.dirname(rcstack.config_file) | ||||
with rcextensions_modification(rcstack_location, mods): | ||||
stdout, stderr = _add_files_and_push( | ||||
'hg', tmpdir.strpath, clone_url=clone_url) | ||||
assert 'HOOK_FAIL_TEST_HG' in stdout | ||||
def test_push_when_rcextensions_fail_git(self, rcstack, tmpdir, user_util, rcextensions, rcextensions_modification): | ||||
repo = user_util.create_repo(repo_type='git') | ||||
clone_url = rcstack.repo_clone_url(repo.repo_name) | ||||
Command(os.path.dirname(tmpdir.strpath)).execute( | ||||
'git clone', clone_url, tmpdir.strpath) | ||||
stdout, stderr = _add_files_and_push( | ||||
'git', tmpdir.strpath, clone_url=clone_url) | ||||
_check_proper_git_push(stdout, stderr) | ||||
mods = [ | ||||
('_pre_push_hook', | ||||
""" | ||||
return HookResponse(1, 'HOOK_FAIL_TEST_GIT') | ||||
""") | ||||
] | ||||
rcstack_location = os.path.dirname(rcstack.config_file) | ||||
with rcextensions_modification(rcstack_location, mods): | ||||
stdout, stderr = _add_files_and_push( | ||||
'git', tmpdir.strpath, clone_url=clone_url) | ||||
assert 'HOOK_FAIL_TEST_GIT' in stderr | ||||