# HG changeset patch # User Marcin Kuzminski # Date 2019-08-19 10:50:23 # Node ID a66c5e676f787e88e7b0865e65169cad2e32d942 # Parent 761273d61c757b68332a70228e13bd3459a71353 tests: fixes for commit pages changes. diff --git a/rhodecode/apps/repository/tests/test_repo_commit_comments.py b/rhodecode/apps/repository/tests/test_repo_commit_comments.py --- a/rhodecode/apps/repository/tests/test_repo_commit_comments.py +++ b/rhodecode/apps/repository/tests/test_repo_commit_comments.py @@ -299,14 +299,14 @@ class TestRepoCommitCommentsView(TestCon def assert_comment_links(response, comments, inline_comments): if comments == 1: - comments_text = "%d Commit comment" % comments + comments_text = "%d General" % comments else: - comments_text = "%d Commit comments" % comments + comments_text = "%d General" % comments if inline_comments == 1: - inline_comments_text = "%d Inline Comment" % inline_comments + inline_comments_text = "%d Inline" % inline_comments else: - inline_comments_text = "%d Inline Comments" % inline_comments + inline_comments_text = "%d Inline" % inline_comments if comments: response.mustcontain('%s,' % comments_text) @@ -315,6 +315,6 @@ def assert_comment_links(response, comme if inline_comments: response.mustcontain( - 'id="inline-comments-counter">%s%s' % inline_comments_text) else: response.mustcontain(inline_comments_text) diff --git a/rhodecode/apps/repository/tests/test_repo_commits.py b/rhodecode/apps/repository/tests/test_repo_commits.py --- a/rhodecode/apps/repository/tests/test_repo_commits.py +++ b/rhodecode/apps/repository/tests/test_repo_commits.py @@ -20,6 +20,7 @@ import pytest +from rhodecode.apps.repository.tests.test_repo_compare import ComparePage from rhodecode.lib.helpers import _shorten_commit_id @@ -80,18 +81,21 @@ class TestRepoCommitView(object): 'svn': '337', } diff_stat = { - 'git': '20 files changed: 941 inserted, 286 deleted', - 'svn': '21 files changed: 943 inserted, 288 deleted', - 'hg': '21 files changed: 943 inserted, 288 deleted', + 'hg': (21, 943, 288), + 'git': (20, 941, 286), + 'svn': (21, 943, 288), + } - } commit_id = commit_id[backend.alias] response = self.app.get(route_path( 'repo_commit', repo_name=backend.repo_name, commit_id=commit_id)) response.mustcontain(_shorten_commit_id(commit_id)) - response.mustcontain(diff_stat[backend.alias]) + + compare_page = ComparePage(response) + file_changes = diff_stat[backend.alias] + compare_page.contains_change_summary(*file_changes) # files op files response.mustcontain('File not present at commit: %s' % @@ -127,24 +131,24 @@ class TestRepoCommitView(object): response.mustcontain(_shorten_commit_id(commit_ids[0])) response.mustcontain(_shorten_commit_id(commit_ids[1])) + compare_page = ComparePage(response) + # svn is special if backend.alias == 'svn': response.mustcontain('new file 10644') - response.mustcontain('1 file changed: 5 inserted, 1 deleted') - response.mustcontain('12 files changed: 236 inserted, 22 deleted') - response.mustcontain('21 files changed: 943 inserted, 288 deleted') + for file_changes in [(1, 5, 1), (12, 236, 22), (21, 943, 288)]: + compare_page.contains_change_summary(*file_changes) elif backend.alias == 'git': response.mustcontain('new file 100644') - response.mustcontain('12 files changed: 222 inserted, 20 deleted') - response.mustcontain('20 files changed: 941 inserted, 286 deleted') + for file_changes in [(12, 222, 20), (20, 941, 286)]: + compare_page.contains_change_summary(*file_changes) else: response.mustcontain('new file 100644') - response.mustcontain('12 files changed: 222 inserted, 20 deleted') - response.mustcontain('21 files changed: 943 inserted, 288 deleted') + for file_changes in [(12, 222, 20), (21, 943, 288)]: + compare_page.contains_change_summary(*file_changes) # files op files - response.mustcontain('File not present at commit: %s' % - _shorten_commit_id(commit_ids[1])) + response.mustcontain('File not present at commit: %s' % _shorten_commit_id(commit_ids[1])) response.mustcontain('Added docstrings to vcs.cli') # commit msg response.mustcontain('Changed theme to ADC theme') # commit msg @@ -176,16 +180,21 @@ class TestRepoCommitView(object): response.mustcontain('File not present at commit: %s' % _shorten_commit_id(commit_ids[1])) + compare_page = ComparePage(response) + # svn is special if backend.alias == 'svn': response.mustcontain('new file 10644') - response.mustcontain('32 files changed: 1179 inserted, 310 deleted') + file_changes = (32, 1179, 310) + compare_page.contains_change_summary(*file_changes) elif backend.alias == 'git': response.mustcontain('new file 100644') - response.mustcontain('31 files changed: 1163 inserted, 306 deleted') + file_changes = (31, 1163, 306) + compare_page.contains_change_summary(*file_changes) else: response.mustcontain('new file 100644') - response.mustcontain('32 files changed: 1165 inserted, 308 deleted') + file_changes = (32, 1165, 308) + compare_page.contains_change_summary(*file_changes) response.mustcontain('Added docstrings to vcs.cli') # commit msg response.mustcontain('Changed theme to ADC theme') # commit msg @@ -313,6 +322,6 @@ Added a symlink # right pane diff menus if right_menu: - for elem in ['Hide whitespace changes', 'Toggle Wide Mode diff', + for elem in ['Hide whitespace changes', 'Toggle wide diff', 'Show full context diff']: response.mustcontain(elem) diff --git a/rhodecode/apps/repository/tests/test_repo_compare.py b/rhodecode/apps/repository/tests/test_repo_compare.py --- a/rhodecode/apps/repository/tests/test_repo_compare.py +++ b/rhodecode/apps/repository/tests/test_repo_compare.py @@ -623,8 +623,8 @@ class ComparePage(AssertResponse): def contains_change_summary(self, files_changed, inserted, deleted): template = ( - "{files_changed} file{plural} changed: " - "{inserted} inserted, {deleted} deleted") + '{files_changed} file{plural} changed: ' + '{inserted} inserted, {deleted} deleted') self.response.mustcontain(template.format( files_changed=files_changed, plural="s" if files_changed > 1 else "", diff --git a/rhodecode/apps/repository/tests/test_repo_compare_on_single_file.py b/rhodecode/apps/repository/tests/test_repo_compare_on_single_file.py --- a/rhodecode/apps/repository/tests/test_repo_compare_on_single_file.py +++ b/rhodecode/apps/repository/tests/test_repo_compare_on_single_file.py @@ -20,6 +20,7 @@ import pytest +from rhodecode.apps.repository.tests.test_repo_compare import ComparePage from rhodecode.lib.vcs import nodes from rhodecode.lib.vcs.backends.base import EmptyCommit from rhodecode.tests.fixture import Fixture @@ -49,18 +50,18 @@ class TestSideBySideDiff(object): 'hg': { 'commits': ['25d7e49c18b159446cadfa506a5cf8ad1cb04067', '603d6c72c46d953420c89d36372f08d9f305f5dd'], - 'changes': '21 files changed: 943 inserted, 288 deleted' + 'changes': (21, 943, 288), }, 'git': { 'commits': ['6fc9270775aaf5544c1deb014f4ddd60c952fcbb', '03fa803d7e9fb14daa9a3089e0d1494eda75d986'], - 'changes': '20 files changed: 941 inserted, 286 deleted' + 'changes': (20, 941, 286), }, 'svn': { 'commits': ['336', '337'], - 'changes': '21 files changed: 943 inserted, 288 deleted' + 'changes': (21, 943, 288), }, } @@ -79,7 +80,8 @@ class TestSideBySideDiff(object): params=dict(target_repo=backend.repo_name, diffmode='sidebyside') )) - response.mustcontain(file_changes) + compare_page = ComparePage(response) + compare_page.contains_change_summary(*file_changes) response.mustcontain('Expand 1 commit') def test_diff_sidebyside_two_commits(self, app, backend): @@ -87,18 +89,18 @@ class TestSideBySideDiff(object): 'hg': { 'commits': ['4fdd71e9427417b2e904e0464c634fdee85ec5a7', '603d6c72c46d953420c89d36372f08d9f305f5dd'], - 'changes': '32 files changed: 1165 inserted, 308 deleted' + 'changes': (32, 1165, 308), }, 'git': { 'commits': ['f5fbf9cfd5f1f1be146f6d3b38bcd791a7480c13', '03fa803d7e9fb14daa9a3089e0d1494eda75d986'], - 'changes': '31 files changed: 1163 inserted, 306 deleted' + 'changes': (31, 1163, 306), }, 'svn': { 'commits': ['335', '337'], - 'changes': '32 files changed: 1179 inserted, 310 deleted' + 'changes': (32, 1179, 310), }, } @@ -117,7 +119,9 @@ class TestSideBySideDiff(object): params=dict(target_repo=backend.repo_name, diffmode='sidebyside') )) - response.mustcontain(file_changes) + compare_page = ComparePage(response) + compare_page.contains_change_summary(*file_changes) + response.mustcontain('Expand 2 commits') @pytest.mark.xfail(reason='GIT does not handle empty commit compare correct (missing 1 commit)') @@ -152,7 +156,7 @@ class TestSideBySideDiff(object): 'r%s:%s...r%s:%s' % ( commit1.idx, commit1.short_id, commit2.idx, commit2.short_id)) - response.mustcontain('{}'.format(f_path)) + response.mustcontain(f_path) @pytest.mark.xfail(reason='GIT does not handle empty commit compare correct (missing 1 commit)') def test_diff_side_by_side_from_0_commit_with_file_filter(self, app, backend, backend_stub): @@ -186,7 +190,7 @@ class TestSideBySideDiff(object): 'r%s:%s...r%s:%s' % ( commit1.idx, commit1.short_id, commit2.idx, commit2.short_id)) - response.mustcontain('{}'.format(f_path)) + response.mustcontain(f_path) def test_diff_side_by_side_with_empty_file(self, app, backend, backend_stub): commits = [ @@ -218,25 +222,25 @@ class TestSideBySideDiff(object): 'r%s:%s...r%s:%s' % ( commit2.idx, commit2.short_id, commit3.idx, commit3.short_id)) - response.mustcontain('{}'.format(f_path)) + response.mustcontain(f_path) def test_diff_sidebyside_two_commits_with_file_filter(self, app, backend): commit_id_range = { 'hg': { 'commits': ['4fdd71e9427417b2e904e0464c634fdee85ec5a7', '603d6c72c46d953420c89d36372f08d9f305f5dd'], - 'changes': '1 file changed: 3 inserted, 3 deleted' + 'changes': (1, 3, 3) }, 'git': { 'commits': ['f5fbf9cfd5f1f1be146f6d3b38bcd791a7480c13', '03fa803d7e9fb14daa9a3089e0d1494eda75d986'], - 'changes': '1 file changed: 3 inserted, 3 deleted' + 'changes': (1, 3, 3) }, 'svn': { 'commits': ['335', '337'], - 'changes': '1 file changed: 3 inserted, 3 deleted' + 'changes': (1, 3, 3) }, } f_path = 'docs/conf.py' @@ -256,4 +260,6 @@ class TestSideBySideDiff(object): )) response.mustcontain('Expand 2 commits') - response.mustcontain(file_changes) + + compare_page = ComparePage(response) + compare_page.contains_change_summary(*file_changes) diff --git a/rhodecode/apps/repository/tests/test_repo_files.py b/rhodecode/apps/repository/tests/test_repo_files.py --- a/rhodecode/apps/repository/tests/test_repo_files.py +++ b/rhodecode/apps/repository/tests/test_repo_files.py @@ -23,6 +23,7 @@ import os import mock import pytest +from rhodecode.apps.repository.tests.test_repo_compare import ComparePage from rhodecode.apps.repository.views.repo_files import RepoFilesView from rhodecode.lib import helpers as h from rhodecode.lib.compat import OrderedDict @@ -617,7 +618,10 @@ class TestFilesDiff(object): # use redirect since this is OLD view redirecting to compare page response = response.follow() response.mustcontain('Expand 1 commit') - response.mustcontain('1 file changed: 0 inserted, 0 deleted') + file_changes = (1, 0, 0) + + compare_page = ComparePage(response) + compare_page.contains_change_summary(*file_changes) if backend.alias == 'svn': response.mustcontain('new file 10644')