##// END OF EJS Templates
fixed import
fixed import

File last commit:

r5608:6d33e504 default
r5659:822bcfab default
Show More
test_vcs_operations_new_branch_push.py
117 lines | 4.7 KiB | text/x-python | PythonLexer
/ rhodecode / tests / vcs_operations / test_vcs_operations_new_branch_push.py
core: updated copyright to 2024
r5608 # Copyright (C) 2010-2024 RhodeCode GmbH
branch-permissions: handle vcs operations and branch permissions....
r2979 #
# 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 import TEST_USER_ADMIN_LOGIN
from rhodecode.tests.vcs_operations import (
Command, _check_proper_hg_push, _check_proper_git_push, _add_files_and_push)
tests: fixed test suite for celery adoption
r5607 @pytest.mark.usefixtures(
"init_pyramid_app",
"repo_group_repos",
"disable_anonymous_user",
)
class TestVCSOperationsNewBranchPush(object):
branch-permissions: handle vcs operations and branch permissions....
r2979
tests: fixed test suite for celery adoption
r5607 def test_push_new_branch_hg(self, rcstack, tmpdir, user_util):
branch-permissions: handle vcs operations and branch permissions....
r2979 repo = user_util.create_repo(repo_type='hg')
tests: fixed test suite for celery adoption
r5607 clone_url = rcstack.repo_clone_url(repo.repo_name)
branch-permissions: handle vcs operations and branch permissions....
r2979 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)
# start new branch, and push file into it
Command(tmpdir.strpath).execute(
'hg branch dev && hg commit -m "starting dev branch"')
stdout, stderr = _add_files_and_push(
'hg', tmpdir.strpath, clone_url=clone_url, target_branch='dev',
new_branch=True)
_check_proper_hg_push(stdout, stderr)
tests: fixed test suite for celery adoption
r5607 def test_push_new_branch_git(self, rcstack, tmpdir, user_util):
branch-permissions: handle vcs operations and branch permissions....
r2979 repo = user_util.create_repo(repo_type='git')
tests: fixed test suite for celery adoption
r5607 clone_url = rcstack.repo_clone_url(repo.repo_name)
branch-permissions: handle vcs operations and branch permissions....
r2979 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)
# start new branch, and push file into it
Command(tmpdir.strpath).execute('git checkout -b dev')
stdout, stderr = _add_files_and_push(
'git', tmpdir.strpath, clone_url=clone_url, target_branch='dev',
new_branch=True)
_check_proper_git_push(stdout, stderr, branch='dev')
def test_push_new_branch_hg_with_branch_permissions_no_force_push(
tests: fixed test suite for celery adoption
r5607 self, rcstack, tmpdir, user_util, branch_permission_setter):
branch-permissions: handle vcs operations and branch permissions....
r2979 repo = user_util.create_repo(repo_type='hg')
repo_name = repo.repo_name
username = TEST_USER_ADMIN_LOGIN
branch_permission_setter(repo_name, username, permission='branch.push')
tests: fixed test suite for celery adoption
r5607 clone_url = rcstack.repo_clone_url(repo.repo_name)
branch-permissions: handle vcs operations and branch permissions....
r2979 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)
# start new branch, and push file into it
Command(tmpdir.strpath).execute(
'hg branch dev && hg commit -m "starting dev branch"')
stdout, stderr = _add_files_and_push(
'hg', tmpdir.strpath, clone_url=clone_url, target_branch='dev',
new_branch=True)
_check_proper_hg_push(stdout, stderr)
def test_push_new_branch_git_with_branch_permissions_no_force_push(
tests: fixed test suite for celery adoption
r5607 self, rcstack, tmpdir, user_util, branch_permission_setter):
branch-permissions: handle vcs operations and branch permissions....
r2979 repo = user_util.create_repo(repo_type='git')
repo_name = repo.repo_name
username = TEST_USER_ADMIN_LOGIN
branch_permission_setter(repo_name, username, permission='branch.push')
tests: fixed test suite for celery adoption
r5607 clone_url = rcstack.repo_clone_url(repo.repo_name)
branch-permissions: handle vcs operations and branch permissions....
r2979 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)
# start new branch, and push file into it
Command(tmpdir.strpath).execute('git checkout -b dev')
stdout, stderr = _add_files_and_push(
'git', tmpdir.strpath, clone_url=clone_url, target_branch='dev',
new_branch=True)
_check_proper_git_push(stdout, stderr, branch='dev')