##// END OF EJS Templates
docs: added newline
docs: added newline

File last commit:

r5608:6d33e504 default
r5656:629f48be default
Show More
test_repo_commits.py
315 lines | 11.1 KiB | text/x-python | PythonLexer
core: updated copyright to 2024
r5608 # Copyright (C) 2010-2024 RhodeCode GmbH
repo-commits: ported changeset code into pyramid views....
r1951 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import pytest
tests: fixes for commit pages changes.
r3885 from rhodecode.apps.repository.tests.test_repo_compare import ComparePage
repo-commits: ported changeset code into pyramid views....
r1951 from rhodecode.lib.helpers import _shorten_commit_id
tests: refactor code to use a single test url generator
r5173 from rhodecode.tests.routes import route_path
repo-commits: ported changeset code into pyramid views....
r1951
@pytest.mark.usefixtures("app")
class TestRepoCommitView(object):
def test_show_commit(self, backend):
commit_id = self.commit_id[backend.alias]
response = self.app.get(route_path(
'repo_commit', repo_name=backend.repo_name, commit_id=commit_id))
response.mustcontain('Added a symlink')
response.mustcontain(commit_id)
response.mustcontain('No newline at end of file')
def test_show_raw(self, backend):
commit_id = self.commit_id[backend.alias]
tests: fixed all tests for python3 BIG changes
r5087 # webtest uses linter to check if response is bytes,
# and we use memoryview here as a wrapper, quick turn-off
self.app.lint = False
repo-commits: ported changeset code into pyramid views....
r1951 response = self.app.get(route_path(
'repo_commit_raw',
repo_name=backend.repo_name, commit_id=commit_id))
tests: fixed all tests for python3 BIG changes
r5087 assert response.body == self.diffs[backend.alias]
repo-commits: ported changeset code into pyramid views....
r1951
def test_show_raw_patch(self, backend):
response = self.app.get(route_path(
'repo_commit_patch', repo_name=backend.repo_name,
commit_id=self.commit_id[backend.alias]))
tests: fixed all tests for python3 BIG changes
r5087 assert response.body == self.patches[backend.alias]
repo-commits: ported changeset code into pyramid views....
r1951
def test_commit_download(self, backend):
tests: fixed all tests for python3 BIG changes
r5087 # webtest uses linter to check if response is bytes,
# and we use memoryview here as a wrapper, quick turn-off
self.app.lint = False
repo-commits: ported changeset code into pyramid views....
r1951 response = self.app.get(route_path(
'repo_commit_download',
repo_name=backend.repo_name,
commit_id=self.commit_id[backend.alias]))
tests: fixed all tests for python3 BIG changes
r5087 assert response.body == self.diffs[backend.alias]
repo-commits: ported changeset code into pyramid views....
r1951
def test_single_commit_page_different_ops(self, backend):
commit_id = {
'hg': '603d6c72c46d953420c89d36372f08d9f305f5dd',
'git': '03fa803d7e9fb14daa9a3089e0d1494eda75d986',
'svn': '337',
}
tests: fixes after some later code changes
r3873 diff_stat = {
tests: fixes for commit pages changes.
r3885 'hg': (21, 943, 288),
'git': (20, 941, 286),
'svn': (21, 943, 288),
}
tests: fixes after some later code changes
r3873
repo-commits: ported changeset code into pyramid views....
r1951 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))
tests: fixes for commit pages changes.
r3885
compare_page = ComparePage(response)
file_changes = diff_stat[backend.alias]
compare_page.contains_change_summary(*file_changes)
repo-commits: ported changeset code into pyramid views....
r1951
# files op files
compare: fixed case of cross repo compare before links not working.
r3146 response.mustcontain('File not present at commit: %s' %
repo-commits: ported changeset code into pyramid views....
r1951 _shorten_commit_id(commit_id))
# svn uses a different filename
if backend.alias == 'svn':
response.mustcontain('new file 10644')
else:
response.mustcontain('new file 100644')
response.mustcontain('Changed theme to ADC theme') # commit msg
self._check_new_diff_menus(response, right_menu=True)
def test_commit_range_page_different_ops(self, backend):
commit_id_range = {
'hg': (
'25d7e49c18b159446cadfa506a5cf8ad1cb04067',
'603d6c72c46d953420c89d36372f08d9f305f5dd'),
'git': (
'6fc9270775aaf5544c1deb014f4ddd60c952fcbb',
'03fa803d7e9fb14daa9a3089e0d1494eda75d986'),
'svn': (
'335',
'337'),
}
commit_ids = commit_id_range[backend.alias]
commit_id = '%s...%s' % (commit_ids[0], commit_ids[1])
response = self.app.get(route_path(
'repo_commit',
repo_name=backend.repo_name, commit_id=commit_id))
response.mustcontain(_shorten_commit_id(commit_ids[0]))
response.mustcontain(_shorten_commit_id(commit_ids[1]))
tests: fixes for commit pages changes.
r3885 compare_page = ComparePage(response)
repo-commits: ported changeset code into pyramid views....
r1951 # svn is special
if backend.alias == 'svn':
response.mustcontain('new file 10644')
tests: fixes for commit pages changes.
r3885 for file_changes in [(1, 5, 1), (12, 236, 22), (21, 943, 288)]:
compare_page.contains_change_summary(*file_changes)
tests: fixes after some later code changes
r3873 elif backend.alias == 'git':
response.mustcontain('new file 100644')
tests: fixes for commit pages changes.
r3885 for file_changes in [(12, 222, 20), (20, 941, 286)]:
compare_page.contains_change_summary(*file_changes)
repo-commits: ported changeset code into pyramid views....
r1951 else:
response.mustcontain('new file 100644')
tests: fixes for commit pages changes.
r3885 for file_changes in [(12, 222, 20), (21, 943, 288)]:
compare_page.contains_change_summary(*file_changes)
repo-commits: ported changeset code into pyramid views....
r1951
# files op files
tests: fixes for commit pages changes.
r3885 response.mustcontain('File not present at commit: %s' % _shorten_commit_id(commit_ids[1]))
repo-commits: ported changeset code into pyramid views....
r1951 response.mustcontain('Added docstrings to vcs.cli') # commit msg
response.mustcontain('Changed theme to ADC theme') # commit msg
self._check_new_diff_menus(response)
def test_combined_compare_commit_page_different_ops(self, backend):
commit_id_range = {
'hg': (
'4fdd71e9427417b2e904e0464c634fdee85ec5a7',
'603d6c72c46d953420c89d36372f08d9f305f5dd'),
'git': (
'f5fbf9cfd5f1f1be146f6d3b38bcd791a7480c13',
'03fa803d7e9fb14daa9a3089e0d1494eda75d986'),
'svn': (
'335',
'337'),
}
commit_ids = commit_id_range[backend.alias]
response = self.app.get(route_path(
'repo_compare',
repo_name=backend.repo_name,
source_ref_type='rev', source_ref=commit_ids[0],
target_ref_type='rev', target_ref=commit_ids[1], ))
response.mustcontain(_shorten_commit_id(commit_ids[0]))
response.mustcontain(_shorten_commit_id(commit_ids[1]))
# files op files
compare: fixed case of cross repo compare before links not working.
r3146 response.mustcontain('File not present at commit: %s' %
repo-commits: ported changeset code into pyramid views....
r1951 _shorten_commit_id(commit_ids[1]))
tests: fixes for commit pages changes.
r3885 compare_page = ComparePage(response)
repo-commits: ported changeset code into pyramid views....
r1951 # svn is special
if backend.alias == 'svn':
response.mustcontain('new file 10644')
tests: fixes for commit pages changes.
r3885 file_changes = (32, 1179, 310)
compare_page.contains_change_summary(*file_changes)
tests: fixes after some later code changes
r3873 elif backend.alias == 'git':
response.mustcontain('new file 100644')
tests: fixes for commit pages changes.
r3885 file_changes = (31, 1163, 306)
compare_page.contains_change_summary(*file_changes)
repo-commits: ported changeset code into pyramid views....
r1951 else:
response.mustcontain('new file 100644')
tests: fixes for commit pages changes.
r3885 file_changes = (32, 1165, 308)
compare_page.contains_change_summary(*file_changes)
repo-commits: ported changeset code into pyramid views....
r1951
response.mustcontain('Added docstrings to vcs.cli') # commit msg
response.mustcontain('Changed theme to ADC theme') # commit msg
self._check_new_diff_menus(response)
def test_changeset_range(self, backend):
self._check_changeset_range(
backend, self.commit_id_range, self.commit_id_range_result)
def test_changeset_range_with_initial_commit(self, backend):
commit_id_range = {
'hg': (
'b986218ba1c9b0d6a259fac9b050b1724ed8e545'
'...6cba7170863a2411822803fa77a0a264f1310b35'),
'git': (
'c1214f7e79e02fc37156ff215cd71275450cffc3'
'...fa6600f6848800641328adbf7811fd2372c02ab2'),
'svn': '1...3',
}
commit_id_range_result = {
'hg': ['b986218ba1c9', '3d8f361e72ab', '6cba7170863a'],
'git': ['c1214f7e79e0', '38b5fe81f109', 'fa6600f68488'],
'svn': ['1', '2', '3'],
}
self._check_changeset_range(
backend, commit_id_range, commit_id_range_result)
def _check_changeset_range(
self, backend, commit_id_ranges, commit_id_range_result):
response = self.app.get(
route_path('repo_commit',
repo_name=backend.repo_name,
commit_id=commit_id_ranges[backend.alias]))
expected_result = commit_id_range_result[backend.alias]
response.mustcontain('{} commits'.format(len(expected_result)))
for commit_id in expected_result:
response.mustcontain(commit_id)
commit_id = {
'hg': '2062ec7beeeaf9f44a1c25c41479565040b930b2',
'svn': '393',
'git': 'fd627b9e0dd80b47be81af07c4a98518244ed2f7',
}
commit_id_range = {
'hg': (
'a53d9201d4bc278910d416d94941b7ea007ecd52'
'...2062ec7beeeaf9f44a1c25c41479565040b930b2'),
'git': (
'7ab37bc680b4aa72c34d07b230c866c28e9fc204'
'...fd627b9e0dd80b47be81af07c4a98518244ed2f7'),
'svn': '391...393',
}
commit_id_range_result = {
'hg': ['a53d9201d4bc', '96507bd11ecc', '2062ec7beeea'],
'git': ['7ab37bc680b4', '5f2c6ee19592', 'fd627b9e0dd8'],
'svn': ['391', '392', '393'],
}
diffs = {
tests: fixed all tests for python3 BIG changes
r5087 'hg': br"""diff --git a/README b/README
repo-commits: ported changeset code into pyramid views....
r1951 new file mode 120000
--- /dev/null
+++ b/README
@@ -0,0 +1,1 @@
+README.rst
\ No newline at end of file
""",
tests: fixed all tests for python3 BIG changes
r5087 'git': br"""diff --git a/README b/README
repo-commits: ported changeset code into pyramid views....
r1951 new file mode 120000
tests: fixes after some later code changes
r3873 index 0000000..92cacd2
repo-commits: ported changeset code into pyramid views....
r1951 --- /dev/null
+++ b/README
@@ -0,0 +1 @@
+README.rst
\ No newline at end of file
""",
tests: fixed all tests for python3 BIG changes
r5087 'svn': b"""Index: README
repo-commits: ported changeset code into pyramid views....
r1951 ===================================================================
diff --git a/README b/README
new file mode 10644
--- /dev/null\t(revision 0)
+++ b/README\t(revision 393)
@@ -0,0 +1 @@
+link README.rst
\\ No newline at end of file
""",
}
patches = {
tests: fixed all tests for python3 BIG changes
r5087 'hg': br"""# HG changeset patch
repo-commits: ported changeset code into pyramid views....
r1951 # User Marcin Kuzminski <marcin@python-works.com>
# Date 2014-01-07 12:21:40
# Node ID 2062ec7beeeaf9f44a1c25c41479565040b930b2
# Parent 96507bd11ecc815ebc6270fdf6db110928c09c1e
Added a symlink
""" + diffs['hg'],
tests: fixed all tests for python3 BIG changes
r5087 'git': br"""From fd627b9e0dd80b47be81af07c4a98518244ed2f7 2014-01-07 12:22:20
repo-commits: ported changeset code into pyramid views....
r1951 From: Marcin Kuzminski <marcin@python-works.com>
Date: 2014-01-07 12:22:20
Subject: [PATCH] Added a symlink
---
""" + diffs['git'],
tests: fixed all tests for python3 BIG changes
r5087 'svn': br"""# SVN changeset patch
repo-commits: ported changeset code into pyramid views....
r1951 # User marcin
# Date 2014-09-02 12:25:22.071142
# Revision 393
Added a symlink
""" + diffs['svn'],
}
dan
diffs: exclude +/- from diffs generation and make then a non-selectable markers visible only via CSS.
r3135 def _check_new_diff_menus(self, response, right_menu=False,):
# individual file diff menus
for elem in ['Show file before', 'Show file after']:
repo-commits: ported changeset code into pyramid views....
r1951 response.mustcontain(elem)
# right pane diff menus
if right_menu:
tests: fixes for commit pages changes.
r3885 for elem in ['Hide whitespace changes', 'Toggle wide diff',
dan
diffs: exclude +/- from diffs generation and make then a non-selectable markers visible only via CSS.
r3135 'Show full context diff']:
repo-commits: ported changeset code into pyramid views....
r1951 response.mustcontain(elem)