tests: fixing tests for pull-requests and changelog(commits)
This commit is contained in:
parent
245e83d2bf
commit
929deba1dd
6 changed files with 27 additions and 23 deletions
|
|
@ -37,11 +37,11 @@ class TestCommentCommit(object):
|
|||
assert_error(id_, expected, given=response.body)
|
||||
|
||||
@pytest.mark.parametrize("commit_id, expected_err", [
|
||||
('abcabca', {'hg': 'Commit {commit} does not exist for {repo}',
|
||||
'git': 'Commit {commit} does not exist for {repo}',
|
||||
('abcabca', {'hg': 'Commit {commit} does not exist for `{repo}`',
|
||||
'git': 'Commit {commit} does not exist for `{repo}`',
|
||||
'svn': 'Commit id {commit} not understood.'}),
|
||||
('idontexist', {'hg': 'Commit {commit} does not exist for {repo}',
|
||||
'git': 'Commit {commit} does not exist for {repo}',
|
||||
('idontexist', {'hg': 'Commit {commit} does not exist for `{repo}`',
|
||||
'git': 'Commit {commit} does not exist for `{repo}`',
|
||||
'svn': 'Commit id {commit} not understood.'}),
|
||||
])
|
||||
def test_api_comment_commit_wrong_hash(self, backend, commit_id, expected_err):
|
||||
|
|
@ -53,7 +53,7 @@ class TestCommentCommit(object):
|
|||
|
||||
expected_err = expected_err[backend.alias]
|
||||
expected_err = expected_err.format(
|
||||
repo=backend.repo.scm_instance(), commit=commit_id)
|
||||
repo=backend.repo.scm_instance().name, commit=commit_id)
|
||||
assert_error(id_, expected_err, given=response.body)
|
||||
|
||||
@pytest.mark.parametrize("status_change, message, commit_id", [
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ def route_path(name, params=None, **kwargs):
|
|||
class TestPullRequestList(object):
|
||||
|
||||
@pytest.mark.parametrize('params, expected_title', [
|
||||
({'source': 0, 'closed': 1}, 'Closed Pull Requests'),
|
||||
({'source': 0, 'my': 1}, 'opened by me'),
|
||||
({'source': 0, 'awaiting_review': 1}, 'awaiting review'),
|
||||
({'source': 0, 'awaiting_my_review': 1}, 'awaiting my review'),
|
||||
({'source': 1}, 'Pull Requests from'),
|
||||
({'source': 0, 'closed': 1}, 'Closed'),
|
||||
({'source': 0, 'my': 1}, 'Opened by me'),
|
||||
({'source': 0, 'awaiting_review': 1}, 'Awaiting review'),
|
||||
({'source': 0, 'awaiting_my_review': 1}, 'Awaiting my review'),
|
||||
({'source': 1}, 'From this repo'),
|
||||
])
|
||||
def test_showing_list_page(self, backend, pr_util, params, expected_title):
|
||||
pull_request = pr_util.create_pull_request()
|
||||
|
|
@ -55,9 +55,10 @@ class TestPullRequestList(object):
|
|||
params=params))
|
||||
|
||||
assert_response = response.assert_response()
|
||||
assert_response.element_equals_to('.panel-title', expected_title)
|
||||
element = assert_response.get_element('.panel-title')
|
||||
element_text = assert_response._element_to_string(element)
|
||||
|
||||
element = assert_response.get_element('.title .active')
|
||||
element_text = element.text_content()
|
||||
assert expected_title == element_text
|
||||
|
||||
def test_showing_list_page_data(self, backend, pr_util, xhr_header):
|
||||
pull_request = pr_util.create_pull_request()
|
||||
|
|
|
|||
|
|
@ -156,22 +156,27 @@ class TestChangelogController(TestController):
|
|||
def assert_commit_range_on_page(
|
||||
self, response, first_idx, last_idx, backend):
|
||||
input_template = (
|
||||
"""<input class="commit-range" id="%(raw_id)s" """
|
||||
"""<input class="commit-range" """
|
||||
"""data-commit-id="%(raw_id)s" data-commit-idx="%(idx)s" id="%(raw_id)s" """
|
||||
"""name="%(raw_id)s" type="checkbox" value="1" />"""
|
||||
)
|
||||
|
||||
commit_span_template = """<span class="commit_hash">r%s:%s</span>"""
|
||||
repo = backend.repo
|
||||
|
||||
first_commit_on_page = repo.get_commit(commit_idx=first_idx)
|
||||
response.mustcontain(
|
||||
input_template % {'raw_id': first_commit_on_page.raw_id})
|
||||
input_template % {'raw_id': first_commit_on_page.raw_id,
|
||||
'idx': first_commit_on_page.idx})
|
||||
|
||||
response.mustcontain(commit_span_template % (
|
||||
first_commit_on_page.idx, first_commit_on_page.short_id)
|
||||
)
|
||||
|
||||
last_commit_on_page = repo.get_commit(commit_idx=last_idx)
|
||||
response.mustcontain(
|
||||
input_template % {'raw_id': last_commit_on_page.raw_id})
|
||||
input_template % {'raw_id': last_commit_on_page.raw_id,
|
||||
'idx': last_commit_on_page.idx})
|
||||
response.mustcontain(commit_span_template % (
|
||||
last_commit_on_page.idx, last_commit_on_page.short_id)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -234,8 +234,7 @@ class GitCommit(base.BaseCommit):
|
|||
path = self._fix_path(path)
|
||||
if self._get_kind(path) != NodeKind.FILE:
|
||||
raise CommitError(
|
||||
"File does not exist for commit %s at '%s'" %
|
||||
(self.raw_id, path))
|
||||
"File does not exist for commit %s at '%s'" % (self.raw_id, path))
|
||||
return path
|
||||
|
||||
def _get_file_nodes(self):
|
||||
|
|
@ -353,8 +352,7 @@ class GitCommit(base.BaseCommit):
|
|||
def get_nodes(self, path):
|
||||
if self._get_kind(path) != NodeKind.DIR:
|
||||
raise CommitError(
|
||||
"Directory does not exist for commit %s at "
|
||||
" '%s'" % (self.raw_id, path))
|
||||
"Directory does not exist for commit %s at '%s'" % (self.raw_id, path))
|
||||
path = self._fix_path(path)
|
||||
id_, _ = self._get_id_for_path(path)
|
||||
tree_id = self._remote[id_]['id']
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ class GitRepository(BaseRepository):
|
|||
try:
|
||||
commit_id_or_idx = self.commit_ids[int(commit_id_or_idx)]
|
||||
except Exception:
|
||||
msg = "Commit %s does not exist for %s" % (commit_id_or_idx, self.name)
|
||||
msg = "Commit {} does not exist for `{}`".format(commit_id_or_idx, self.name)
|
||||
raise CommitDoesNotExistError(msg)
|
||||
|
||||
elif is_bstr:
|
||||
|
|
@ -262,7 +262,7 @@ class GitRepository(BaseRepository):
|
|||
|
||||
if (not SHA_PATTERN.match(commit_id_or_idx) or
|
||||
commit_id_or_idx not in self.commit_ids):
|
||||
msg = "Commit %s does not exist for %s" % (commit_id_or_idx, self.name)
|
||||
msg = "Commit {} does not exist for `{}`".format(commit_id_or_idx, self.name)
|
||||
raise CommitDoesNotExistError(msg)
|
||||
|
||||
# Ensure we return full id
|
||||
|
|
|
|||
|
|
@ -456,7 +456,7 @@ class MercurialRepository(BaseRepository):
|
|||
try:
|
||||
raw_id, idx = self._remote.lookup(commit_id, both=True)
|
||||
except CommitDoesNotExistError:
|
||||
msg = "Commit {} does not exist for {}".format(
|
||||
msg = "Commit {} does not exist for `{}`".format(
|
||||
*map(safe_str, [commit_id, self.name]))
|
||||
raise CommitDoesNotExistError(msg)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue