##// END OF EJS Templates
repositories: use remote function to check if repo is empty...
repositories: use remote function to check if repo is empty - changed 2 cases where we want to check for None instead of __bool__ of repo object

File last commit:

r3363:f08e98b1 default
r3723:267daa27 new-ui
Show More
test_pullrequest_git.py
71 lines | 3.0 KiB | text/x-python | PythonLexer
/ rhodecode / tests / models / test_pullrequest_git.py
project: added all source files and assets
r1 # -*- coding: utf-8 -*-
docs: updated copyrights to 2019
r3363 # Copyright (C) 2010-2019 RhodeCode GmbH
project: added all source files and assets
r1 #
# 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 pytest
from rhodecode.lib.vcs.nodes import FileNode
from rhodecode.lib.vcs.exceptions import CommitDoesNotExistError
from rhodecode.model.pull_request import PullRequestModel
home: moved home and repo group views into pyramid....
r1774 @pytest.mark.usefixtures('config_stub')
project: added all source files and assets
r1 @pytest.mark.backends('git')
class TestGetDiffForPrOrVersion(object):
def test_works_for_missing_git_references(self, pr_util):
pull_request = self._prepare_pull_request(pr_util)
removed_commit_id = pr_util.remove_one_commit()
self.assert_commit_cannot_be_accessed(removed_commit_id, pull_request)
self.assert_diff_can_be_fetched(pull_request)
def test_works_for_missing_git_references_during_update(self, pr_util):
pull_request = self._prepare_pull_request(pr_util)
removed_commit_id = pr_util.remove_one_commit()
self.assert_commit_cannot_be_accessed(removed_commit_id, pull_request)
pr_version = PullRequestModel().get_versions(pull_request)[0]
self.assert_diff_can_be_fetched(pr_version)
def _prepare_pull_request(self, pr_util):
commits = [
{'message': 'a'},
{'message': 'b', 'added': [FileNode('file_b', 'test_content\n')]},
{'message': 'c', 'added': [FileNode('file_c', 'test_content\n')]},
]
pull_request = pr_util.create_pull_request(
commits=commits, target_head='a', source_head='c',
revisions=['b', 'c'])
return pull_request
def assert_diff_can_be_fetched(self, pr_or_version):
test: fixes for tests for PR versions.
r1373 source_repo = pr_or_version.source_repo
source_ref_id = pr_or_version.source_ref_parts.commit_id
target_ref_id = pr_or_version.target_ref_parts.commit_id
project: added all source files and assets
r1 diff = PullRequestModel()._get_diff_from_pr_or_version(
dan
diffs: introducing diff menu for whitespace toggle and context changes
r3134 source_repo, source_ref_id, target_ref_id,
hide_whitespace_changes=False, diff_context=6)
project: added all source files and assets
r1 assert 'file_b' in diff.raw
def assert_commit_cannot_be_accessed(
self, removed_commit_id, pull_request):
source_vcs = pull_request.source_repo.scm_instance()
with pytest.raises(CommitDoesNotExistError):
source_vcs.get_commit(commit_id=removed_commit_id)