##// END OF EJS Templates
fixed VCS tests after executable big issue was fixed
marcink -
r3854:d7a5da0d default
parent child Browse files
Show More
@@ -1,183 +1,183
1 from __future__ import with_statement
1 from __future__ import with_statement
2
2
3 import stat
3 import stat
4 from rhodecode.lib.vcs.nodes import DirNode
4 from rhodecode.lib.vcs.nodes import DirNode
5 from rhodecode.lib.vcs.nodes import FileNode
5 from rhodecode.lib.vcs.nodes import FileNode
6 from rhodecode.lib.vcs.nodes import Node
6 from rhodecode.lib.vcs.nodes import Node
7 from rhodecode.lib.vcs.nodes import NodeError
7 from rhodecode.lib.vcs.nodes import NodeError
8 from rhodecode.lib.vcs.nodes import NodeKind
8 from rhodecode.lib.vcs.nodes import NodeKind
9 from rhodecode.lib.vcs.utils.compat import unittest
9 from rhodecode.lib.vcs.utils.compat import unittest
10
10
11
11
12 class NodeBasicTest(unittest.TestCase):
12 class NodeBasicTest(unittest.TestCase):
13
13
14 def test_init(self):
14 def test_init(self):
15 """
15 """
16 Cannot innitialize Node objects with path with slash at the beginning.
16 Cannot innitialize Node objects with path with slash at the beginning.
17 """
17 """
18 wrong_paths = (
18 wrong_paths = (
19 '/foo',
19 '/foo',
20 '/foo/bar'
20 '/foo/bar'
21 )
21 )
22 for path in wrong_paths:
22 for path in wrong_paths:
23 self.assertRaises(NodeError, Node, path, NodeKind.FILE)
23 self.assertRaises(NodeError, Node, path, NodeKind.FILE)
24
24
25 wrong_paths = (
25 wrong_paths = (
26 '/foo/',
26 '/foo/',
27 '/foo/bar/'
27 '/foo/bar/'
28 )
28 )
29 for path in wrong_paths:
29 for path in wrong_paths:
30 self.assertRaises(NodeError, Node, path, NodeKind.DIR)
30 self.assertRaises(NodeError, Node, path, NodeKind.DIR)
31
31
32 def test_name(self):
32 def test_name(self):
33 node = Node('', NodeKind.DIR)
33 node = Node('', NodeKind.DIR)
34 self.assertEqual(node.name, '')
34 self.assertEqual(node.name, '')
35
35
36 node = Node('path', NodeKind.FILE)
36 node = Node('path', NodeKind.FILE)
37 self.assertEqual(node.name, 'path')
37 self.assertEqual(node.name, 'path')
38
38
39 node = Node('path/', NodeKind.DIR)
39 node = Node('path/', NodeKind.DIR)
40 self.assertEqual(node.name, 'path')
40 self.assertEqual(node.name, 'path')
41
41
42 node = Node('some/path', NodeKind.FILE)
42 node = Node('some/path', NodeKind.FILE)
43 self.assertEqual(node.name, 'path')
43 self.assertEqual(node.name, 'path')
44
44
45 node = Node('some/path/', NodeKind.DIR)
45 node = Node('some/path/', NodeKind.DIR)
46 self.assertEqual(node.name, 'path')
46 self.assertEqual(node.name, 'path')
47
47
48 def test_root_node(self):
48 def test_root_node(self):
49 self.assertRaises(NodeError, Node, '', NodeKind.FILE)
49 self.assertRaises(NodeError, Node, '', NodeKind.FILE)
50
50
51 def test_kind_setter(self):
51 def test_kind_setter(self):
52 node = Node('', NodeKind.DIR)
52 node = Node('', NodeKind.DIR)
53 self.assertRaises(NodeError, setattr, node, 'kind', NodeKind.FILE)
53 self.assertRaises(NodeError, setattr, node, 'kind', NodeKind.FILE)
54
54
55 def _test_parent_path(self, node_path, expected_parent_path):
55 def _test_parent_path(self, node_path, expected_parent_path):
56 """
56 """
57 Tests if node's parent path are properly computed.
57 Tests if node's parent path are properly computed.
58 """
58 """
59 node = Node(node_path, NodeKind.DIR)
59 node = Node(node_path, NodeKind.DIR)
60 parent_path = node.get_parent_path()
60 parent_path = node.get_parent_path()
61 self.assertTrue(parent_path.endswith('/') or \
61 self.assertTrue(parent_path.endswith('/') or \
62 node.is_root() and parent_path == '')
62 node.is_root() and parent_path == '')
63 self.assertEqual(parent_path, expected_parent_path,
63 self.assertEqual(parent_path, expected_parent_path,
64 "Node's path is %r and parent path is %r but should be %r"
64 "Node's path is %r and parent path is %r but should be %r"
65 % (node.path, parent_path, expected_parent_path))
65 % (node.path, parent_path, expected_parent_path))
66
66
67 def test_parent_path(self):
67 def test_parent_path(self):
68 test_paths = (
68 test_paths = (
69 # (node_path, expected_parent_path)
69 # (node_path, expected_parent_path)
70 ('', ''),
70 ('', ''),
71 ('some/path/', 'some/'),
71 ('some/path/', 'some/'),
72 ('some/longer/path/', 'some/longer/'),
72 ('some/longer/path/', 'some/longer/'),
73 )
73 )
74 for node_path, expected_parent_path in test_paths:
74 for node_path, expected_parent_path in test_paths:
75 self._test_parent_path(node_path, expected_parent_path)
75 self._test_parent_path(node_path, expected_parent_path)
76
76
77 '''
77 '''
78 def _test_trailing_slash(self, path):
78 def _test_trailing_slash(self, path):
79 if not path.endswith('/'):
79 if not path.endswith('/'):
80 self.fail("Trailing slash tests needs paths to end with slash")
80 self.fail("Trailing slash tests needs paths to end with slash")
81 for kind in NodeKind.FILE, NodeKind.DIR:
81 for kind in NodeKind.FILE, NodeKind.DIR:
82 self.assertRaises(NodeError, Node, path=path, kind=kind)
82 self.assertRaises(NodeError, Node, path=path, kind=kind)
83
83
84 def test_trailing_slash(self):
84 def test_trailing_slash(self):
85 for path in ('/', 'foo/', 'foo/bar/', 'foo/bar/biz/'):
85 for path in ('/', 'foo/', 'foo/bar/', 'foo/bar/biz/'):
86 self._test_trailing_slash(path)
86 self._test_trailing_slash(path)
87 '''
87 '''
88
88
89 def test_is_file(self):
89 def test_is_file(self):
90 node = Node('any', NodeKind.FILE)
90 node = Node('any', NodeKind.FILE)
91 self.assertTrue(node.is_file())
91 self.assertTrue(node.is_file())
92
92
93 node = FileNode('any')
93 node = FileNode('any')
94 self.assertTrue(node.is_file())
94 self.assertTrue(node.is_file())
95 self.assertRaises(AttributeError, getattr, node, 'nodes')
95 self.assertRaises(AttributeError, getattr, node, 'nodes')
96
96
97 def test_is_dir(self):
97 def test_is_dir(self):
98 node = Node('any_dir', NodeKind.DIR)
98 node = Node('any_dir', NodeKind.DIR)
99 self.assertTrue(node.is_dir())
99 self.assertTrue(node.is_dir())
100
100
101 node = DirNode('any_dir')
101 node = DirNode('any_dir')
102
102
103 self.assertTrue(node.is_dir())
103 self.assertTrue(node.is_dir())
104 self.assertRaises(NodeError, getattr, node, 'content')
104 self.assertRaises(NodeError, getattr, node, 'content')
105
105
106 def test_dir_node_iter(self):
106 def test_dir_node_iter(self):
107 nodes = [
107 nodes = [
108 DirNode('docs'),
108 DirNode('docs'),
109 DirNode('tests'),
109 DirNode('tests'),
110 FileNode('bar'),
110 FileNode('bar'),
111 FileNode('foo'),
111 FileNode('foo'),
112 FileNode('readme.txt'),
112 FileNode('readme.txt'),
113 FileNode('setup.py'),
113 FileNode('setup.py'),
114 ]
114 ]
115 dirnode = DirNode('', nodes=nodes)
115 dirnode = DirNode('', nodes=nodes)
116 for node in dirnode:
116 for node in dirnode:
117 node == dirnode.get_node(node.path)
117 node == dirnode.get_node(node.path)
118
118
119 def test_node_state(self):
119 def test_node_state(self):
120 """
120 """
121 Without link to changeset nodes should raise NodeError.
121 Without link to changeset nodes should raise NodeError.
122 """
122 """
123 node = FileNode('anything')
123 node = FileNode('anything')
124 self.assertRaises(NodeError, getattr, node, 'state')
124 self.assertRaises(NodeError, getattr, node, 'state')
125 node = DirNode('anything')
125 node = DirNode('anything')
126 self.assertRaises(NodeError, getattr, node, 'state')
126 self.assertRaises(NodeError, getattr, node, 'state')
127
127
128 def test_file_node_stat(self):
128 def test_file_node_stat(self):
129 node = FileNode('foobar', 'empty... almost')
129 node = FileNode('foobar', 'empty... almost')
130 mode = node.mode # default should be 0100644
130 mode = node.mode # default should be 0100644
131 self.assertTrue(mode & stat.S_IRUSR)
131 self.assertTrue(mode & stat.S_IRUSR)
132 self.assertTrue(mode & stat.S_IWUSR)
132 self.assertTrue(mode & stat.S_IWUSR)
133 self.assertTrue(mode & stat.S_IRGRP)
133 self.assertTrue(mode & stat.S_IRGRP)
134 self.assertTrue(mode & stat.S_IROTH)
134 self.assertTrue(mode & stat.S_IROTH)
135 self.assertFalse(mode & stat.S_IWGRP)
135 self.assertFalse(mode & stat.S_IWGRP)
136 self.assertFalse(mode & stat.S_IWOTH)
136 self.assertFalse(mode & stat.S_IWOTH)
137 self.assertFalse(mode & stat.S_IXUSR)
137 self.assertFalse(mode & stat.S_IXUSR)
138 self.assertFalse(mode & stat.S_IXGRP)
138 self.assertFalse(mode & stat.S_IXGRP)
139 self.assertFalse(mode & stat.S_IXOTH)
139 self.assertFalse(mode & stat.S_IXOTH)
140
140
141 def test_file_node_is_executable(self):
141 def test_file_node_is_executable(self):
142 node = FileNode('foobar', 'empty... almost', mode=0100755)
142 node = FileNode('foobar', 'empty... almost', mode=0100755)
143 self.assertTrue(node.is_executable())
143 self.assertTrue(node.is_executable)
144
144
145 node = FileNode('foobar', 'empty... almost', mode=0100500)
145 node = FileNode('foobar', 'empty... almost', mode=0100500)
146 self.assertTrue(node.is_executable())
146 self.assertTrue(node.is_executable)
147
147
148 node = FileNode('foobar', 'empty... almost', mode=0100644)
148 node = FileNode('foobar', 'empty... almost', mode=0100644)
149 self.assertFalse(node.is_executable())
149 self.assertFalse(node.is_executable)
150
150
151 def test_mimetype(self):
151 def test_mimetype(self):
152 py_node = FileNode('test.py')
152 py_node = FileNode('test.py')
153 tar_node = FileNode('test.tar.gz')
153 tar_node = FileNode('test.tar.gz')
154
154
155 ext = 'CustomExtension'
155 ext = 'CustomExtension'
156
156
157 my_node2 = FileNode('myfile2')
157 my_node2 = FileNode('myfile2')
158 my_node2._mimetype = [ext]
158 my_node2._mimetype = [ext]
159
159
160 my_node3 = FileNode('myfile3')
160 my_node3 = FileNode('myfile3')
161 my_node3._mimetype = [ext,ext]
161 my_node3._mimetype = [ext,ext]
162
162
163 self.assertEqual(py_node.mimetype,'text/x-python')
163 self.assertEqual(py_node.mimetype,'text/x-python')
164 self.assertEqual(py_node.get_mimetype(),('text/x-python',None))
164 self.assertEqual(py_node.get_mimetype(),('text/x-python',None))
165
165
166 self.assertEqual(tar_node.mimetype,'application/x-tar')
166 self.assertEqual(tar_node.mimetype,'application/x-tar')
167 self.assertEqual(tar_node.get_mimetype(),('application/x-tar','gzip'))
167 self.assertEqual(tar_node.get_mimetype(),('application/x-tar','gzip'))
168
168
169 self.assertRaises(NodeError,my_node2.get_mimetype)
169 self.assertRaises(NodeError,my_node2.get_mimetype)
170
170
171 self.assertEqual(my_node3.mimetype,ext)
171 self.assertEqual(my_node3.mimetype,ext)
172 self.assertEqual(my_node3.get_mimetype(),[ext,ext])
172 self.assertEqual(my_node3.get_mimetype(),[ext,ext])
173
173
174 class NodeContentTest(unittest.TestCase):
174 class NodeContentTest(unittest.TestCase):
175
175
176 def test_if_binary(self):
176 def test_if_binary(self):
177 data = """\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f??a\x00\x00\x00\x04gAMA\x00\x00\xaf?7\x05\x8a?\x00\x00\x00\x19tEXtSoftware\x00Adobe ImageReadyq?e<\x00\x00\x025IDAT8?\xa5\x93?K\x94Q\x14\x87\x9f\xf7?Q\x1bs4?\x03\x9a\xa8?B\x02\x8b$\x10[U;i\x13?6h?&h[?"\x14j?\xa2M\x7fB\x14F\x9aQ?&\x842?\x0b\x89"\x82??!?\x9c!\x9c2l??{N\x8bW\x9dY\xb4\t/\x1c?=\x9b?}????\xa9*;9!?\x83\x91?[?\\v*?D\x04\'`EpNp\xa2X\'U?pVq"Sw.\x1e?\x08\x01D?jw????\xbc??7{|\x9b?\x89$\x01??W@\x15\x9c\x05q`Lt/\x97?\x94\xa1d?\x18~?\x18?\x18W[%\xb0?\x83??\x14\x88\x8dB?\xa6H\tL\tl\x19>/\x01`\xac\xabx?\x9cl\nx\xb0\x98\x07\x95\x88D$"q[\x19?d\x00(o\n\xa0??\x7f\xb9\xa4?\x1bF\x1f\x8e\xac\xa8?j??eUU}?.?\x9f\x8cE??x\x94??\r\xbdtoJU5"0N\x10U?\x00??V\t\x02\x9f\x81?U?\x00\x9eM\xae2?r\x9b7\x83\x82\x8aP3????.?&"?\xb7ZP \x0c<?O\xa5\t}\xb8?\x99\xa6?\x87?\x1di|/\xa0??0\xbe\x1fp?d&\x1a\xad\x95\x8a\x07?\t*\x10??b:?d?.\x13C\x8a?\x12\xbe\xbf\x8e?{???\x08?\x80\xa7\x13+d\x13>J?\x80\x15T\x95\x9a\x00??S\x8c\r?\xa1\x03\x07?\x96\x9b\xa7\xab=E??\xa4\xb3?\x19q??B\x91=\x8d??k?J\x0bV"??\xf7x?\xa1\x00?\\.\x87\x87???\x02F@D\x99],??\x10#?X\xb7=\xb9\x10?Z\x1by???cI??\x1ag?\x92\xbc?T?t[\x92\x81?<_\x17~\x92\x88?H%?\x10Q\x02\x9f\n\x81qQ\x0bm?\x1bX?\xb1AK\xa6\x9e\xb9?u\xb2?1\xbe|/\x92M@\xa2!F?\xa9>"\r<DT?>\x92\x8e?>\x9a9Qv\x127?a\xac?Y?8?:??]X???9\x80\xb7?u?\x0b#BZ\x8d=\x1d?p\x00\x00\x00\x00IEND\xaeB`\x82"""
177 data = """\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f??a\x00\x00\x00\x04gAMA\x00\x00\xaf?7\x05\x8a?\x00\x00\x00\x19tEXtSoftware\x00Adobe ImageReadyq?e<\x00\x00\x025IDAT8?\xa5\x93?K\x94Q\x14\x87\x9f\xf7?Q\x1bs4?\x03\x9a\xa8?B\x02\x8b$\x10[U;i\x13?6h?&h[?"\x14j?\xa2M\x7fB\x14F\x9aQ?&\x842?\x0b\x89"\x82??!?\x9c!\x9c2l??{N\x8bW\x9dY\xb4\t/\x1c?=\x9b?}????\xa9*;9!?\x83\x91?[?\\v*?D\x04\'`EpNp\xa2X\'U?pVq"Sw.\x1e?\x08\x01D?jw????\xbc??7{|\x9b?\x89$\x01??W@\x15\x9c\x05q`Lt/\x97?\x94\xa1d?\x18~?\x18?\x18W[%\xb0?\x83??\x14\x88\x8dB?\xa6H\tL\tl\x19>/\x01`\xac\xabx?\x9cl\nx\xb0\x98\x07\x95\x88D$"q[\x19?d\x00(o\n\xa0??\x7f\xb9\xa4?\x1bF\x1f\x8e\xac\xa8?j??eUU}?.?\x9f\x8cE??x\x94??\r\xbdtoJU5"0N\x10U?\x00??V\t\x02\x9f\x81?U?\x00\x9eM\xae2?r\x9b7\x83\x82\x8aP3????.?&"?\xb7ZP \x0c<?O\xa5\t}\xb8?\x99\xa6?\x87?\x1di|/\xa0??0\xbe\x1fp?d&\x1a\xad\x95\x8a\x07?\t*\x10??b:?d?.\x13C\x8a?\x12\xbe\xbf\x8e?{???\x08?\x80\xa7\x13+d\x13>J?\x80\x15T\x95\x9a\x00??S\x8c\r?\xa1\x03\x07?\x96\x9b\xa7\xab=E??\xa4\xb3?\x19q??B\x91=\x8d??k?J\x0bV"??\xf7x?\xa1\x00?\\.\x87\x87???\x02F@D\x99],??\x10#?X\xb7=\xb9\x10?Z\x1by???cI??\x1ag?\x92\xbc?T?t[\x92\x81?<_\x17~\x92\x88?H%?\x10Q\x02\x9f\n\x81qQ\x0bm?\x1bX?\xb1AK\xa6\x9e\xb9?u\xb2?1\xbe|/\x92M@\xa2!F?\xa9>"\r<DT?>\x92\x8e?>\x9a9Qv\x127?a\xac?Y?8?:??]X???9\x80\xb7?u?\x0b#BZ\x8d=\x1d?p\x00\x00\x00\x00IEND\xaeB`\x82"""
178 filenode = FileNode('calendar.png', content=data)
178 filenode = FileNode('calendar.png', content=data)
179 self.assertTrue(filenode.is_binary)
179 self.assertTrue(filenode.is_binary)
180
180
181
181
182 if __name__ == '__main__':
182 if __name__ == '__main__':
183 unittest.main()
183 unittest.main()
@@ -1,216 +1,216
1 from __future__ import with_statement
1 from __future__ import with_statement
2 import datetime
2 import datetime
3 from base import BackendTestMixin
3 from base import BackendTestMixin
4 from conf import SCM_TESTS
4 from conf import SCM_TESTS
5 from conf import TEST_USER_CONFIG_FILE
5 from conf import TEST_USER_CONFIG_FILE
6 from rhodecode.lib.vcs.nodes import FileNode
6 from rhodecode.lib.vcs.nodes import FileNode
7 from rhodecode.lib.vcs.utils.compat import unittest
7 from rhodecode.lib.vcs.utils.compat import unittest
8 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
8 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
9
9
10
10
11 class RepositoryBaseTest(BackendTestMixin):
11 class RepositoryBaseTest(BackendTestMixin):
12 recreate_repo_per_test = False
12 recreate_repo_per_test = False
13
13
14 @classmethod
14 @classmethod
15 def _get_commits(cls):
15 def _get_commits(cls):
16 return super(RepositoryBaseTest, cls)._get_commits()[:1]
16 return super(RepositoryBaseTest, cls)._get_commits()[:1]
17
17
18 def test_get_config_value(self):
18 def test_get_config_value(self):
19 self.assertEqual(self.repo.get_config_value('universal', 'foo',
19 self.assertEqual(self.repo.get_config_value('universal', 'foo',
20 TEST_USER_CONFIG_FILE), 'bar')
20 TEST_USER_CONFIG_FILE), 'bar')
21
21
22 def test_get_config_value_defaults_to_None(self):
22 def test_get_config_value_defaults_to_None(self):
23 self.assertEqual(self.repo.get_config_value('universal', 'nonexist',
23 self.assertEqual(self.repo.get_config_value('universal', 'nonexist',
24 TEST_USER_CONFIG_FILE), None)
24 TEST_USER_CONFIG_FILE), None)
25
25
26 def test_get_user_name(self):
26 def test_get_user_name(self):
27 self.assertEqual(self.repo.get_user_name(TEST_USER_CONFIG_FILE),
27 self.assertEqual(self.repo.get_user_name(TEST_USER_CONFIG_FILE),
28 'Foo Bar')
28 'Foo Bar')
29
29
30 def test_get_user_email(self):
30 def test_get_user_email(self):
31 self.assertEqual(self.repo.get_user_email(TEST_USER_CONFIG_FILE),
31 self.assertEqual(self.repo.get_user_email(TEST_USER_CONFIG_FILE),
32 'foo.bar@example.com')
32 'foo.bar@example.com')
33
33
34
34
35
35
36 class RepositoryGetDiffTest(BackendTestMixin):
36 class RepositoryGetDiffTest(BackendTestMixin):
37
37
38 @classmethod
38 @classmethod
39 def _get_commits(cls):
39 def _get_commits(cls):
40 commits = [
40 commits = [
41 {
41 {
42 'message': 'Initial commit',
42 'message': 'Initial commit',
43 'author': 'Joe Doe <joe.doe@example.com>',
43 'author': 'Joe Doe <joe.doe@example.com>',
44 'date': datetime.datetime(2010, 1, 1, 20),
44 'date': datetime.datetime(2010, 1, 1, 20),
45 'added': [
45 'added': [
46 FileNode('foobar', content='foobar'),
46 FileNode('foobar', content='foobar'),
47 FileNode('foobar2', content='foobar2'),
47 FileNode('foobar2', content='foobar2'),
48 ],
48 ],
49 },
49 },
50 {
50 {
51 'message': 'Changed foobar, added foobar3',
51 'message': 'Changed foobar, added foobar3',
52 'author': 'Jane Doe <jane.doe@example.com>',
52 'author': 'Jane Doe <jane.doe@example.com>',
53 'date': datetime.datetime(2010, 1, 1, 21),
53 'date': datetime.datetime(2010, 1, 1, 21),
54 'added': [
54 'added': [
55 FileNode('foobar3', content='foobar3'),
55 FileNode('foobar3', content='foobar3'),
56 ],
56 ],
57 'changed': [
57 'changed': [
58 FileNode('foobar', 'FOOBAR'),
58 FileNode('foobar', 'FOOBAR'),
59 ],
59 ],
60 },
60 },
61 {
61 {
62 'message': 'Removed foobar, changed foobar3',
62 'message': 'Removed foobar, changed foobar3',
63 'author': 'Jane Doe <jane.doe@example.com>',
63 'author': 'Jane Doe <jane.doe@example.com>',
64 'date': datetime.datetime(2010, 1, 1, 22),
64 'date': datetime.datetime(2010, 1, 1, 22),
65 'changed': [
65 'changed': [
66 FileNode('foobar3', content='FOOBAR\nFOOBAR\nFOOBAR\n'),
66 FileNode('foobar3', content='FOOBAR\nFOOBAR\nFOOBAR\n'),
67 ],
67 ],
68 'removed': [FileNode('foobar')],
68 'removed': [FileNode('foobar')],
69 },
69 },
70 ]
70 ]
71 return commits
71 return commits
72
72
73 def test_raise_for_wrong(self):
73 def test_raise_for_wrong(self):
74 with self.assertRaises(ChangesetDoesNotExistError):
74 with self.assertRaises(ChangesetDoesNotExistError):
75 self.repo.get_diff('a' * 40, 'b' * 40)
75 self.repo.get_diff('a' * 40, 'b' * 40)
76
76
77
77
78 class GitRepositoryGetDiffTest(RepositoryGetDiffTest, unittest.TestCase):
78 class GitRepositoryGetDiffTest(RepositoryGetDiffTest, unittest.TestCase):
79 backend_alias = 'git'
79 backend_alias = 'git'
80
80
81 def test_initial_commit_diff(self):
81 def test_initial_commit_diff(self):
82 initial_rev = self.repo.revisions[0]
82 initial_rev = self.repo.revisions[0]
83 self.assertEqual(self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev), '''diff --git a/foobar b/foobar
83 self.assertEqual(self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev), '''diff --git a/foobar b/foobar
84 new file mode 100644
84 new file mode 100644
85 index 0000000000000000000000000000000000000000..f6ea0495187600e7b2288c8ac19c5886383a4632
85 index 0000000000000000000000000000000000000000..f6ea0495187600e7b2288c8ac19c5886383a4632
86 --- /dev/null
86 --- /dev/null
87 +++ b/foobar
87 +++ b/foobar
88 @@ -0,0 +1 @@
88 @@ -0,0 +1 @@
89 +foobar
89 +foobar
90 \ No newline at end of file
90 \ No newline at end of file
91 diff --git a/foobar2 b/foobar2
91 diff --git a/foobar2 b/foobar2
92 new file mode 100644
92 new file mode 100644
93 index 0000000000000000000000000000000000000000..e8c9d6b98e3dce993a464935e1a53f50b56a3783
93 index 0000000000000000000000000000000000000000..e8c9d6b98e3dce993a464935e1a53f50b56a3783
94 --- /dev/null
94 --- /dev/null
95 +++ b/foobar2
95 +++ b/foobar2
96 @@ -0,0 +1 @@
96 @@ -0,0 +1 @@
97 +foobar2
97 +foobar2
98 \ No newline at end of file
98 \ No newline at end of file
99 ''')
99 ''')
100
100
101 def test_second_changeset_diff(self):
101 def test_second_changeset_diff(self):
102 revs = self.repo.revisions
102 revs = self.repo.revisions
103 self.assertEqual(self.repo.get_diff(revs[0], revs[1]), '''diff --git a/foobar b/foobar
103 self.assertEqual(self.repo.get_diff(revs[0], revs[1]), '''diff --git a/foobar b/foobar
104 index f6ea0495187600e7b2288c8ac19c5886383a4632..389865bb681b358c9b102d79abd8d5f941e96551 100644
104 index f6ea0495187600e7b2288c8ac19c5886383a4632..389865bb681b358c9b102d79abd8d5f941e96551 100644
105 --- a/foobar
105 --- a/foobar
106 +++ b/foobar
106 +++ b/foobar
107 @@ -1 +1 @@
107 @@ -1 +1 @@
108 -foobar
108 -foobar
109 \ No newline at end of file
109 \ No newline at end of file
110 +FOOBAR
110 +FOOBAR
111 \ No newline at end of file
111 \ No newline at end of file
112 diff --git a/foobar3 b/foobar3
112 diff --git a/foobar3 b/foobar3
113 new file mode 100644
113 new file mode 100644
114 index 0000000000000000000000000000000000000000..c11c37d41d33fb47741cff93fa5f9d798c1535b0
114 index 0000000000000000000000000000000000000000..c11c37d41d33fb47741cff93fa5f9d798c1535b0
115 --- /dev/null
115 --- /dev/null
116 +++ b/foobar3
116 +++ b/foobar3
117 @@ -0,0 +1 @@
117 @@ -0,0 +1 @@
118 +foobar3
118 +foobar3
119 \ No newline at end of file
119 \ No newline at end of file
120 ''')
120 ''')
121
121
122 def test_third_changeset_diff(self):
122 def test_third_changeset_diff(self):
123 revs = self.repo.revisions
123 revs = self.repo.revisions
124 self.assertEqual(self.repo.get_diff(revs[1], revs[2]), '''diff --git a/foobar b/foobar
124 self.assertEqual(self.repo.get_diff(revs[1], revs[2]), '''diff --git a/foobar b/foobar
125 deleted file mode 100644
125 deleted file mode 100644
126 index 389865bb681b358c9b102d79abd8d5f941e96551..0000000000000000000000000000000000000000
126 index 389865bb681b358c9b102d79abd8d5f941e96551..0000000000000000000000000000000000000000
127 --- a/foobar
127 --- a/foobar
128 +++ /dev/null
128 +++ /dev/null
129 @@ -1 +0,0 @@
129 @@ -1 +0,0 @@
130 -FOOBAR
130 -FOOBAR
131 \ No newline at end of file
131 \ No newline at end of file
132 diff --git a/foobar3 b/foobar3
132 diff --git a/foobar3 b/foobar3
133 index c11c37d41d33fb47741cff93fa5f9d798c1535b0..f9324477362684ff692aaf5b9a81e01b9e9a671c 100644
133 index c11c37d41d33fb47741cff93fa5f9d798c1535b0..f9324477362684ff692aaf5b9a81e01b9e9a671c 100644
134 --- a/foobar3
134 --- a/foobar3
135 +++ b/foobar3
135 +++ b/foobar3
136 @@ -1 +1,3 @@
136 @@ -1 +1,3 @@
137 -foobar3
137 -foobar3
138 \ No newline at end of file
138 \ No newline at end of file
139 +FOOBAR
139 +FOOBAR
140 +FOOBAR
140 +FOOBAR
141 +FOOBAR
141 +FOOBAR
142 ''')
142 ''')
143
143
144
144
145 class HgRepositoryGetDiffTest(RepositoryGetDiffTest, unittest.TestCase):
145 class HgRepositoryGetDiffTest(RepositoryGetDiffTest, unittest.TestCase):
146 backend_alias = 'hg'
146 backend_alias = 'hg'
147
147
148 def test_initial_commit_diff(self):
148 def test_initial_commit_diff(self):
149 initial_rev = self.repo.revisions[0]
149 initial_rev = self.repo.revisions[0]
150 self.assertEqual(self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev), '''diff --git a/foobar b/foobar
150 self.assertEqual(self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev), '''diff --git a/foobar b/foobar
151 new file mode 100755
151 new file mode 100644
152 --- /dev/null
152 --- /dev/null
153 +++ b/foobar
153 +++ b/foobar
154 @@ -0,0 +1,1 @@
154 @@ -0,0 +1,1 @@
155 +foobar
155 +foobar
156 \ No newline at end of file
156 \ No newline at end of file
157 diff --git a/foobar2 b/foobar2
157 diff --git a/foobar2 b/foobar2
158 new file mode 100755
158 new file mode 100644
159 --- /dev/null
159 --- /dev/null
160 +++ b/foobar2
160 +++ b/foobar2
161 @@ -0,0 +1,1 @@
161 @@ -0,0 +1,1 @@
162 +foobar2
162 +foobar2
163 \ No newline at end of file
163 \ No newline at end of file
164 ''')
164 ''')
165
165
166 def test_second_changeset_diff(self):
166 def test_second_changeset_diff(self):
167 revs = self.repo.revisions
167 revs = self.repo.revisions
168 self.assertEqual(self.repo.get_diff(revs[0], revs[1]), '''diff --git a/foobar b/foobar
168 self.assertEqual(self.repo.get_diff(revs[0], revs[1]), '''diff --git a/foobar b/foobar
169 --- a/foobar
169 --- a/foobar
170 +++ b/foobar
170 +++ b/foobar
171 @@ -1,1 +1,1 @@
171 @@ -1,1 +1,1 @@
172 -foobar
172 -foobar
173 \ No newline at end of file
173 \ No newline at end of file
174 +FOOBAR
174 +FOOBAR
175 \ No newline at end of file
175 \ No newline at end of file
176 diff --git a/foobar3 b/foobar3
176 diff --git a/foobar3 b/foobar3
177 new file mode 100755
177 new file mode 100644
178 --- /dev/null
178 --- /dev/null
179 +++ b/foobar3
179 +++ b/foobar3
180 @@ -0,0 +1,1 @@
180 @@ -0,0 +1,1 @@
181 +foobar3
181 +foobar3
182 \ No newline at end of file
182 \ No newline at end of file
183 ''')
183 ''')
184
184
185 def test_third_changeset_diff(self):
185 def test_third_changeset_diff(self):
186 revs = self.repo.revisions
186 revs = self.repo.revisions
187 self.assertEqual(self.repo.get_diff(revs[1], revs[2]), '''diff --git a/foobar b/foobar
187 self.assertEqual(self.repo.get_diff(revs[1], revs[2]), '''diff --git a/foobar b/foobar
188 deleted file mode 100755
188 deleted file mode 100644
189 --- a/foobar
189 --- a/foobar
190 +++ /dev/null
190 +++ /dev/null
191 @@ -1,1 +0,0 @@
191 @@ -1,1 +0,0 @@
192 -FOOBAR
192 -FOOBAR
193 \ No newline at end of file
193 \ No newline at end of file
194 diff --git a/foobar3 b/foobar3
194 diff --git a/foobar3 b/foobar3
195 --- a/foobar3
195 --- a/foobar3
196 +++ b/foobar3
196 +++ b/foobar3
197 @@ -1,1 +1,3 @@
197 @@ -1,1 +1,3 @@
198 -foobar3
198 -foobar3
199 \ No newline at end of file
199 \ No newline at end of file
200 +FOOBAR
200 +FOOBAR
201 +FOOBAR
201 +FOOBAR
202 +FOOBAR
202 +FOOBAR
203 ''')
203 ''')
204
204
205
205
206 # For each backend create test case class
206 # For each backend create test case class
207 for alias in SCM_TESTS:
207 for alias in SCM_TESTS:
208 attrs = {
208 attrs = {
209 'backend_alias': alias,
209 'backend_alias': alias,
210 }
210 }
211 cls_name = alias.capitalize() + RepositoryBaseTest.__name__
211 cls_name = alias.capitalize() + RepositoryBaseTest.__name__
212 bases = (RepositoryBaseTest, unittest.TestCase)
212 bases = (RepositoryBaseTest, unittest.TestCase)
213 globals()[cls_name] = type(cls_name, bases, attrs)
213 globals()[cls_name] = type(cls_name, bases, attrs)
214
214
215 if __name__ == '__main__':
215 if __name__ == '__main__':
216 unittest.main()
216 unittest.main()
General Comments 0
You need to be logged in to leave comments. Login now