# HG changeset patch # User Marcin Kuzminski # Date 2019-06-28 12:24:57 # Node ID 5c4b5f3d027ecece008ffd008450252ec58bca1e # Parent c26fb0fb0295f5d7e6f6232f4c589d174a22cab5 tests: fixing tests for pull-requests and changelog(commits) diff --git a/rhodecode/api/tests/test_comment_commit.py b/rhodecode/api/tests/test_comment_commit.py --- a/rhodecode/api/tests/test_comment_commit.py +++ b/rhodecode/api/tests/test_comment_commit.py @@ -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", [ diff --git a/rhodecode/apps/repository/tests/test_pull_requests_list.py b/rhodecode/apps/repository/tests/test_pull_requests_list.py --- a/rhodecode/apps/repository/tests/test_pull_requests_list.py +++ b/rhodecode/apps/repository/tests/test_pull_requests_list.py @@ -40,11 +40,11 @@ def route_path(name, params=None, **kwar 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() diff --git a/rhodecode/apps/repository/tests/test_repo_changelog.py b/rhodecode/apps/repository/tests/test_repo_changelog.py --- a/rhodecode/apps/repository/tests/test_repo_changelog.py +++ b/rhodecode/apps/repository/tests/test_repo_changelog.py @@ -156,22 +156,27 @@ class TestChangelogController(TestContro def assert_commit_range_on_page( self, response, first_idx, last_idx, backend): input_template = ( - """""" ) + commit_span_template = """r%s:%s""" 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) ) diff --git a/rhodecode/lib/vcs/backends/git/commit.py b/rhodecode/lib/vcs/backends/git/commit.py --- a/rhodecode/lib/vcs/backends/git/commit.py +++ b/rhodecode/lib/vcs/backends/git/commit.py @@ -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'] diff --git a/rhodecode/lib/vcs/backends/git/repository.py b/rhodecode/lib/vcs/backends/git/repository.py --- a/rhodecode/lib/vcs/backends/git/repository.py +++ b/rhodecode/lib/vcs/backends/git/repository.py @@ -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 diff --git a/rhodecode/lib/vcs/backends/hg/repository.py b/rhodecode/lib/vcs/backends/hg/repository.py --- a/rhodecode/lib/vcs/backends/hg/repository.py +++ b/rhodecode/lib/vcs/backends/hg/repository.py @@ -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)