##// END OF EJS Templates
tests: fixing tests for pull-requests and changelog(commits)
marcink -
r3772:5c4b5f3d new-ui
parent child Browse files
Show More
@@ -37,11 +37,11 b' class TestCommentCommit(object):'
37 37 assert_error(id_, expected, given=response.body)
38 38
39 39 @pytest.mark.parametrize("commit_id, expected_err", [
40 ('abcabca', {'hg': 'Commit {commit} does not exist for {repo}',
41 'git': 'Commit {commit} does not exist for {repo}',
40 ('abcabca', {'hg': 'Commit {commit} does not exist for `{repo}`',
41 'git': 'Commit {commit} does not exist for `{repo}`',
42 42 'svn': 'Commit id {commit} not understood.'}),
43 ('idontexist', {'hg': 'Commit {commit} does not exist for {repo}',
44 'git': 'Commit {commit} does not exist for {repo}',
43 ('idontexist', {'hg': 'Commit {commit} does not exist for `{repo}`',
44 'git': 'Commit {commit} does not exist for `{repo}`',
45 45 'svn': 'Commit id {commit} not understood.'}),
46 46 ])
47 47 def test_api_comment_commit_wrong_hash(self, backend, commit_id, expected_err):
@@ -53,7 +53,7 b' class TestCommentCommit(object):'
53 53
54 54 expected_err = expected_err[backend.alias]
55 55 expected_err = expected_err.format(
56 repo=backend.repo.scm_instance(), commit=commit_id)
56 repo=backend.repo.scm_instance().name, commit=commit_id)
57 57 assert_error(id_, expected_err, given=response.body)
58 58
59 59 @pytest.mark.parametrize("status_change, message, commit_id", [
@@ -40,11 +40,11 b' def route_path(name, params=None, **kwar'
40 40 class TestPullRequestList(object):
41 41
42 42 @pytest.mark.parametrize('params, expected_title', [
43 ({'source': 0, 'closed': 1}, 'Closed Pull Requests'),
44 ({'source': 0, 'my': 1}, 'opened by me'),
45 ({'source': 0, 'awaiting_review': 1}, 'awaiting review'),
46 ({'source': 0, 'awaiting_my_review': 1}, 'awaiting my review'),
47 ({'source': 1}, 'Pull Requests from'),
43 ({'source': 0, 'closed': 1}, 'Closed'),
44 ({'source': 0, 'my': 1}, 'Opened by me'),
45 ({'source': 0, 'awaiting_review': 1}, 'Awaiting review'),
46 ({'source': 0, 'awaiting_my_review': 1}, 'Awaiting my review'),
47 ({'source': 1}, 'From this repo'),
48 48 ])
49 49 def test_showing_list_page(self, backend, pr_util, params, expected_title):
50 50 pull_request = pr_util.create_pull_request()
@@ -55,9 +55,10 b' class TestPullRequestList(object):'
55 55 params=params))
56 56
57 57 assert_response = response.assert_response()
58 assert_response.element_equals_to('.panel-title', expected_title)
59 element = assert_response.get_element('.panel-title')
60 element_text = assert_response._element_to_string(element)
58
59 element = assert_response.get_element('.title .active')
60 element_text = element.text_content()
61 assert expected_title == element_text
61 62
62 63 def test_showing_list_page_data(self, backend, pr_util, xhr_header):
63 64 pull_request = pr_util.create_pull_request()
@@ -156,22 +156,27 b' class TestChangelogController(TestContro'
156 156 def assert_commit_range_on_page(
157 157 self, response, first_idx, last_idx, backend):
158 158 input_template = (
159 """<input class="commit-range" id="%(raw_id)s" """
159 """<input class="commit-range" """
160 """data-commit-id="%(raw_id)s" data-commit-idx="%(idx)s" id="%(raw_id)s" """
160 161 """name="%(raw_id)s" type="checkbox" value="1" />"""
161 162 )
163
162 164 commit_span_template = """<span class="commit_hash">r%s:%s</span>"""
163 165 repo = backend.repo
164 166
165 167 first_commit_on_page = repo.get_commit(commit_idx=first_idx)
166 168 response.mustcontain(
167 input_template % {'raw_id': first_commit_on_page.raw_id})
169 input_template % {'raw_id': first_commit_on_page.raw_id,
170 'idx': first_commit_on_page.idx})
171
168 172 response.mustcontain(commit_span_template % (
169 173 first_commit_on_page.idx, first_commit_on_page.short_id)
170 174 )
171 175
172 176 last_commit_on_page = repo.get_commit(commit_idx=last_idx)
173 177 response.mustcontain(
174 input_template % {'raw_id': last_commit_on_page.raw_id})
178 input_template % {'raw_id': last_commit_on_page.raw_id,
179 'idx': last_commit_on_page.idx})
175 180 response.mustcontain(commit_span_template % (
176 181 last_commit_on_page.idx, last_commit_on_page.short_id)
177 182 )
@@ -234,8 +234,7 b' class GitCommit(base.BaseCommit):'
234 234 path = self._fix_path(path)
235 235 if self._get_kind(path) != NodeKind.FILE:
236 236 raise CommitError(
237 "File does not exist for commit %s at '%s'" %
238 (self.raw_id, path))
237 "File does not exist for commit %s at '%s'" % (self.raw_id, path))
239 238 return path
240 239
241 240 def _get_file_nodes(self):
@@ -353,8 +352,7 b' class GitCommit(base.BaseCommit):'
353 352 def get_nodes(self, path):
354 353 if self._get_kind(path) != NodeKind.DIR:
355 354 raise CommitError(
356 "Directory does not exist for commit %s at "
357 " '%s'" % (self.raw_id, path))
355 "Directory does not exist for commit %s at '%s'" % (self.raw_id, path))
358 356 path = self._fix_path(path)
359 357 id_, _ = self._get_id_for_path(path)
360 358 tree_id = self._remote[id_]['id']
@@ -240,7 +240,7 b' class GitRepository(BaseRepository):'
240 240 try:
241 241 commit_id_or_idx = self.commit_ids[int(commit_id_or_idx)]
242 242 except Exception:
243 msg = "Commit %s does not exist for %s" % (commit_id_or_idx, self.name)
243 msg = "Commit {} does not exist for `{}`".format(commit_id_or_idx, self.name)
244 244 raise CommitDoesNotExistError(msg)
245 245
246 246 elif is_bstr:
@@ -262,7 +262,7 b' class GitRepository(BaseRepository):'
262 262
263 263 if (not SHA_PATTERN.match(commit_id_or_idx) or
264 264 commit_id_or_idx not in self.commit_ids):
265 msg = "Commit %s does not exist for %s" % (commit_id_or_idx, self.name)
265 msg = "Commit {} does not exist for `{}`".format(commit_id_or_idx, self.name)
266 266 raise CommitDoesNotExistError(msg)
267 267
268 268 # Ensure we return full id
@@ -456,7 +456,7 b' class MercurialRepository(BaseRepository'
456 456 try:
457 457 raw_id, idx = self._remote.lookup(commit_id, both=True)
458 458 except CommitDoesNotExistError:
459 msg = "Commit {} does not exist for {}".format(
459 msg = "Commit {} does not exist for `{}`".format(
460 460 *map(safe_str, [commit_id, self.name]))
461 461 raise CommitDoesNotExistError(msg)
462 462
General Comments 0
You need to be logged in to leave comments. Login now