Mercurial > kallithea
changeset 8047:db6573f71b89
tests: fix ordering of get_inline_comments output
Py3 would give different ordering.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sun, 22 Dec 2019 20:28:00 +0100 |
parents | c6f5c3e60329 |
children | 45d71d0a07f2 |
files | kallithea/model/comment.py kallithea/tests/models/test_comments.py |
diffstat | 2 files changed, 16 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/model/comment.py Thu Dec 26 04:53:38 2019 +0100 +++ b/kallithea/model/comment.py Sun Dec 22 20:28:00 2019 +0100 @@ -257,7 +257,7 @@ paths = defaultdict(lambda: defaultdict(list)) for co in comments: paths[co.f_path][co.line_no].append(co) - return paths.items() + return sorted(paths.items()) def _get_comments(self, repo_id, revision=None, pull_request=None, inline=False, f_path=None, line_no=None):
--- a/kallithea/tests/models/test_comments.py Thu Dec 26 04:53:38 2019 +0100 +++ b/kallithea/tests/models/test_comments.py Sun Dec 22 20:28:00 2019 +0100 @@ -126,15 +126,15 @@ expected_len_comments=0, expected_len_inline_comments=2) # inline_comments is a list of tuples (file_path, dict) # where the dict keys are line numbers and values are lists of comments - assert inline_comments[1][0] == f_path - assert len(inline_comments[1][1]) == 2 - assert inline_comments[1][1][line_no][0].text == text - assert inline_comments[1][1][line_no2][0].text == text2 + assert inline_comments[0][0] == f_path + assert len(inline_comments[0][1]) == 2 + assert inline_comments[0][1][line_no][0].text == text + assert inline_comments[0][1][line_no2][0].text == text2 - assert inline_comments[0][0] == f_path3 - assert len(inline_comments[0][1]) == 1 - assert line_no3 in inline_comments[0][1] - assert inline_comments[0][1][line_no3][0].text == text3 + assert inline_comments[1][0] == f_path3 + assert len(inline_comments[1][1]) == 1 + assert line_no3 in inline_comments[1][1] + assert inline_comments[1][1][line_no3][0].text == text3 # now delete only one comment ChangesetCommentsModel().delete(new_comment2) @@ -143,14 +143,14 @@ expected_len_comments=0, expected_len_inline_comments=2) # inline_comments is a list of tuples (file_path, dict) # where the dict keys are line numbers and values are lists of comments - assert inline_comments[1][0] == f_path - assert len(inline_comments[1][1]) == 1 - assert inline_comments[1][1][line_no][0].text == text + assert inline_comments[0][0] == f_path + assert len(inline_comments[0][1]) == 1 + assert inline_comments[0][1][line_no][0].text == text - assert inline_comments[0][0] == f_path3 - assert len(inline_comments[0][1]) == 1 - assert line_no3 in inline_comments[0][1] - assert inline_comments[0][1][line_no3][0].text == text3 + assert inline_comments[1][0] == f_path3 + assert len(inline_comments[1][1]) == 1 + assert line_no3 in inline_comments[1][1] + assert inline_comments[1][1][line_no3][0].text == text3 # now delete all others ChangesetCommentsModel().delete(new_comment)