##// END OF EJS Templates
channelstream: log debug should be lazily evaulated.
channelstream: log debug should be lazily evaulated.

File last commit:

r1807:83e09901 default
r1973:5a20d6ac default
Show More
test_get_pull_request.py
134 lines | 5.3 KiB | text/x-python | PythonLexer
/ rhodecode / api / tests / test_get_pull_request.py
project: added all source files and assets
r1 # -*- coding: utf-8 -*-
license: updated copyright year to 2017
r1271 # Copyright (C) 2010-2017 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
import urlobject
from pylons import url
from rhodecode.api.tests.utils import (
build_data, api_call, assert_error, assert_ok)
home: moved home and repo group views into pyramid....
r1774 from rhodecode.lib.utils2 import safe_unicode
project: added all source files and assets
r1
pytestmark = pytest.mark.backends("git", "hg")
@pytest.mark.usefixtures("testuser_api", "app")
class TestGetPullRequest(object):
audit-logs: implemented pull request and comment events.
r1807 def test_api_get_pull_request(self, pr_util, http_host_only_stub):
Martin Bornhold
tests: Add shadow clone url to expected api return value.
r908 from rhodecode.model.pull_request import PullRequestModel
project: added all source files and assets
r1 pull_request = pr_util.create_pull_request(mergeable=True)
id_, params = build_data(
self.apikey, 'get_pull_request',
repoid=pull_request.target_repo.repo_name,
pullrequestid=pull_request.pull_request_id)
response = api_call(self.app, params)
assert response.status == '200 OK'
url_obj = urlobject.URLObject(
url(
'pullrequest_show',
repo_name=pull_request.target_repo.repo_name,
pull_request_id=pull_request.pull_request_id, qualified=True))
home: moved home and repo group views into pyramid....
r1774
pr_url = safe_unicode(
audit-logs: implemented pull request and comment events.
r1807 url_obj.with_netloc(http_host_only_stub))
home: moved home and repo group views into pyramid....
r1774 source_url = safe_unicode(
pull_request.source_repo.clone_url().with_netloc(http_host_only_stub))
target_url = safe_unicode(
pull_request.target_repo.clone_url().with_netloc(http_host_only_stub))
shadow_url = safe_unicode(
Martin Bornhold
tests: Add shadow clone url to expected api return value.
r908 PullRequestModel().get_shadow_clone_url(pull_request))
home: moved home and repo group views into pyramid....
r1774
project: added all source files and assets
r1 expected = {
'pull_request_id': pull_request.pull_request_id,
'url': pr_url,
'title': pull_request.title,
'description': pull_request.description,
'status': pull_request.status,
'created_on': pull_request.created_on,
'updated_on': pull_request.updated_on,
'commit_ids': pull_request.revisions,
'review_status': pull_request.calculated_review_status(),
'mergeable': {
'status': True,
'message': 'This pull request can be automatically merged.',
},
'source': {
'clone_url': source_url,
'repository': pull_request.source_repo.repo_name,
'reference': {
'name': pull_request.source_ref_parts.name,
'type': pull_request.source_ref_parts.type,
'commit_id': pull_request.source_ref_parts.commit_id,
},
},
'target': {
'clone_url': target_url,
'repository': pull_request.target_repo.repo_name,
'reference': {
'name': pull_request.target_ref_parts.name,
'type': pull_request.target_ref_parts.type,
'commit_id': pull_request.target_ref_parts.commit_id,
},
},
Martin Bornhold
tests: Update expected data from api call.
r1056 'merge': {
Martin Bornhold
tests: Add shadow clone url to expected api return value.
r908 'clone_url': shadow_url,
Martin Bornhold
tests: Update expected data from api call.
r1056 'reference': {
'name': pull_request.shadow_merge_ref.name,
'type': pull_request.shadow_merge_ref.type,
'commit_id': pull_request.shadow_merge_ref.commit_id,
},
Martin Bornhold
tests: Add shadow clone url to expected api return value.
r908 },
project: added all source files and assets
r1 'author': pull_request.author.get_api_data(include_secrets=False,
details='basic'),
'reviewers': [
{
'user': reviewer.get_api_data(include_secrets=False,
details='basic'),
dan
reviewers: store reviewer reasons to database, fixes #4238
r873 'reasons': reasons,
project: added all source files and assets
r1 'review_status': st[0][1].status if st else 'not_reviewed',
}
pull-request: extended default reviewers functionality....
r1769 for reviewer, reasons, mandatory, st in
pull_request.reviewers_statuses()
project: added all source files and assets
r1 ]
}
assert_ok(id_, expected, response.body)
def test_api_get_pull_request_repo_error(self):
id_, params = build_data(
self.apikey, 'get_pull_request',
repoid=666, pullrequestid=1)
response = api_call(self.app, params)
expected = 'repository `666` does not exist'
assert_error(id_, expected, given=response.body)
def test_api_get_pull_request_pull_request_error(self):
id_, params = build_data(
self.apikey, 'get_pull_request',
repoid=1, pullrequestid=666)
response = api_call(self.app, params)
expected = 'pull request `666` does not exist'
assert_error(id_, expected, given=response.body)