##// END OF EJS Templates
use safe get on copy mode since for git we don't have this implemented
use safe get on copy mode since for git we don't have this implemented

File last commit:

r4007:3e8f48cc default
r4013:d9a73bfc default
Show More
test_diff_parsers.py
282 lines | 10.0 KiB | text/x-python | PythonLexer
fix tests for python2.5
r3035 from __future__ import with_statement
Implemented generation of changesets based...
r2995 import os
from rhodecode.tests import *
from rhodecode.lib.diffs import DiffProcessor, NEW_FILENODE, DEL_FILENODE, \
Added handling of copied files diff parsing
r3997 MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE, COPIED_FILENODE
Implemented generation of changesets based...
r2995
dn = os.path.dirname
FIXTURES = os.path.join(dn(dn(os.path.abspath(__file__))), 'fixtures')
DIFF_FIXTURES = {
'hg_diff_add_single_binary_file.diff': [
diff parser: redefined operations stats for changes...
r3821 ('US Warszawa.jpg', 'A',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {NEW_FILENODE: 'new file 100755',
BIN_FILENODE: 'binary diff not shown'}}),
Implemented generation of changesets based...
r2995 ],
'hg_diff_mod_single_binary_file.diff': [
diff parser: redefined operations stats for changes...
r3821 ('US Warszawa.jpg', 'M',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {MOD_FILENODE: 'modified file',
BIN_FILENODE: 'binary diff not shown'}}),
],
'hg_diff_mod_single_file_and_rename_and_chmod.diff': [
('README', 'M',
{'added': 3,
'deleted': 0,
'binary': False,
'ops': {MOD_FILENODE: 'modified file',
RENAMED_FILENODE: 'file renamed from README.rst to README',
CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}),
],
fixed duplicated test in diff tests
r3893 'hg_diff_mod_file_and_rename.diff': [
('README.rst', 'M',
diff parser: redefined operations stats for changes...
r3821 {'added': 3,
'deleted': 0,
'binary': False,
'ops': {MOD_FILENODE: 'modified file',
fixed duplicated test in diff tests
r3893 RENAMED_FILENODE: 'file renamed from README to README.rst'}}),
Implemented generation of changesets based...
r2995 ],
'hg_diff_del_single_binary_file.diff': [
diff parser: redefined operations stats for changes...
r3821 ('US Warszawa.jpg', 'D',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {DEL_FILENODE: 'deleted file',
BIN_FILENODE: 'binary diff not shown'}}),
],
'hg_diff_chmod_and_mod_single_binary_file.diff': [
('gravatar.png', 'M',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755',
BIN_FILENODE: 'binary diff not shown'}}),
],
'hg_diff_chmod.diff': [
('file', 'M',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}),
],
'hg_diff_rename_file.diff': [
('file_renamed', 'M',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {RENAMED_FILENODE: 'file renamed from file to file_renamed'}}),
],
'hg_diff_rename_and_chmod_file.diff': [
('README', 'M',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755',
RENAMED_FILENODE: 'file renamed from README.rst to README'}}),
Implemented generation of changesets based...
r2995 ],
'hg_diff_binary_and_normal.diff': [
diff parser: redefined operations stats for changes...
r3821 ('img/baseline-10px.png', 'A',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {NEW_FILENODE: 'new file 100644',
BIN_FILENODE: 'binary diff not shown'}}),
('js/jquery/hashgrid.js', 'A',
{'added': 340,
'deleted': 0,
'binary': False,
'ops': {NEW_FILENODE: 'new file 100755'}}),
('index.html', 'M',
{'added': 3,
'deleted': 2,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
('less/docs.less', 'M',
{'added': 34,
'deleted': 0,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
('less/scaffolding.less', 'M',
{'added': 1,
'deleted': 3,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
('readme.markdown', 'M',
{'added': 1,
'deleted': 10,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
('img/baseline-20px.png', 'D',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {DEL_FILENODE: 'deleted file',
BIN_FILENODE: 'binary diff not shown'}}),
('js/global.js', 'D',
{'added': 0,
'deleted': 75,
'binary': False,
'ops': {DEL_FILENODE: 'deleted file'}})
Implemented generation of changesets based...
r2995 ],
'git_diff_chmod.diff': [
diff parser: redefined operations stats for changes...
r3821 ('work-horus.xls', 'M',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755'}})
Implemented generation of changesets based...
r2995 ],
'git_diff_rename_file.diff': [
diff parser: redefined operations stats for changes...
r3821 ('file.xls', 'M',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {RENAMED_FILENODE: 'file renamed from work-horus.xls to file.xls'}})
Implemented generation of changesets based...
r2995 ],
'git_diff_mod_single_binary_file.diff': [
diff parser: redefined operations stats for changes...
r3821 ('US Warszawa.jpg', 'M',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {MOD_FILENODE: 'modified file',
BIN_FILENODE: 'binary diff not shown'}})
Implemented generation of changesets based...
r2995 ],
'git_diff_binary_and_normal.diff': [
diff parser: redefined operations stats for changes...
r3821 ('img/baseline-10px.png', 'A',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {NEW_FILENODE: 'new file 100644',
BIN_FILENODE: 'binary diff not shown'}}),
('js/jquery/hashgrid.js', 'A',
{'added': 340,
'deleted': 0,
'binary': False,
'ops': {NEW_FILENODE: 'new file 100755'}}),
('index.html', 'M',
{'added': 3,
'deleted': 2,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
('less/docs.less', 'M',
{'added': 34,
'deleted': 0,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
('less/scaffolding.less', 'M',
{'added': 1,
'deleted': 3,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
('readme.markdown', 'M',
{'added': 1,
'deleted': 10,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
('img/baseline-20px.png', 'D',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {DEL_FILENODE: 'deleted file',
BIN_FILENODE: 'binary diff not shown'}}),
('js/global.js', 'D',
{'added': 0,
'deleted': 75,
'binary': False,
'ops': {DEL_FILENODE: 'deleted file'}}),
Implemented generation of changesets based...
r2995 ],
Fixed issue with inproper handling of diff parsing that could lead to infinit loops....
r3022 'diff_with_diff_data.diff': [
diff parser: redefined operations stats for changes...
r3821 ('vcs/backends/base.py', 'M',
{'added': 18,
'deleted': 2,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
('vcs/backends/git/repository.py', 'M',
{'added': 46,
'deleted': 15,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
('vcs/backends/hg.py', 'M',
{'added': 22,
'deleted': 3,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
('vcs/tests/test_git.py', 'M',
{'added': 5,
'deleted': 5,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
('vcs/tests/test_repository.py', 'M',
{'added': 174,
'deleted': 2,
'binary': False,
'ops': {MOD_FILENODE: 'modified file'}}),
Fixed issue with inproper handling of diff parsing that could lead to infinit loops....
r3022 ],
Added handling of copied files diff parsing
r3997 'hg_diff_copy_file.diff': [
('file2', 'M',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {COPIED_FILENODE: 'file copied from file1 to file2'}}),
Added some missing tests for copy+chmod, copy+chmod+modify...
r4007 ],
'hg_diff_copy_and_modify_file.diff': [
('file3', 'M',
{'added': 1,
'deleted': 0,
'binary': False,
'ops': {COPIED_FILENODE: 'file copied from file2 to file3',
MOD_FILENODE: 'modified file'}}),
],
'hg_diff_copy_and_chmod_file.diff': [
('file4', 'M',
{'added': 0,
'deleted': 0,
'binary': True,
'ops': {COPIED_FILENODE: 'file copied from file3 to file4',
CHMOD_FILENODE: 'modified file chmod 100644 => 100755'}}),
],
'hg_diff_copy_chmod_and_edit_file.diff': [
('file5', 'M',
{'added': 2,
'deleted': 1,
'binary': False,
'ops': {COPIED_FILENODE: 'file copied from file4 to file5',
CHMOD_FILENODE: 'modified file chmod 100755 => 100644',
MOD_FILENODE: 'modified file'}}),
Added handling of copied files diff parsing
r3997 ]
diff parser: redefined operations stats for changes...
r3821 # 'large_diff.diff': [
# ('.hgignore', 'A', {'deleted': 0, 'binary': False, 'added': 3, 'ops': {1: 'new file 100644'}}),
# ('MANIFEST.in', 'A', {'deleted': 0, 'binary': False, 'added': 3, 'ops': {1: 'new file 100644'}}),
# ('README.txt', 'A', {'deleted': 0, 'binary': False, 'added': 19, 'ops': {1: 'new file 100644'}}),
# ('development.ini', 'A', {'deleted': 0, 'binary': False, 'added': 116, 'ops': {1: 'new file 100644'}}),
# ('docs/index.txt', 'A', {'deleted': 0, 'binary': False, 'added': 19, 'ops': {1: 'new file 100644'}}),
# ('ez_setup.py', 'A', {'deleted': 0, 'binary': False, 'added': 276, 'ops': {1: 'new file 100644'}}),
# ('hgapp.py', 'A', {'deleted': 0, 'binary': False, 'added': 26, 'ops': {1: 'new file 100644'}}),
# ('hgwebdir.config', 'A', {'deleted': 0, 'binary': False, 'added': 21, 'ops': {1: 'new file 100644'}}),
# ('pylons_app.egg-info/PKG-INFO', 'A', {'deleted': 0, 'binary': False, 'added': 10, 'ops': {1: 'new file 100644'}}),
# ('pylons_app.egg-info/SOURCES.txt', 'A', {'deleted': 0, 'binary': False, 'added': 33, 'ops': {1: 'new file 100644'}}),
# ('pylons_app.egg-info/dependency_links.txt', 'A', {'deleted': 0, 'binary': False, 'added': 1, 'ops': {1: 'new file 100644'}}),
# #TODO:
# ],
Implemented generation of changesets based...
r2995
}
created basic TestClass for tests that does...
r3829 class DiffLibTest(BaseTestCase):
diff parser: redefined operations stats for changes...
r3821
@parameterized.expand([(x,) for x in DIFF_FIXTURES])
def test_diff(self, diff_fixture):
Implemented generation of changesets based...
r2995
diff parser: redefined operations stats for changes...
r3821 with open(os.path.join(FIXTURES, diff_fixture)) as f:
diff = f.read()
Implemented generation of changesets based...
r2995
diff parser: redefined operations stats for changes...
r3821 diff_proc = DiffProcessor(diff)
diff_proc_d = diff_proc.prepare()
data = [(x['filename'], x['operation'], x['stats']) for x in diff_proc_d]
expected_data = DIFF_FIXTURES[diff_fixture]
self.assertListEqual(expected_data, data)