##// END OF EJS Templates
tests: fixes #4168 unique results for svn changesets in tests
lisaq -
r676:0f26bf80 default
parent child Browse files
Show More
@@ -1,271 +1,286 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2010-2016 RhodeCode GmbH
3 # Copyright (C) 2010-2016 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import pytest
21 import pytest
22
22
23 from rhodecode.lib.helpers import _shorten_commit_id
23 from rhodecode.lib.helpers import _shorten_commit_id
24 from rhodecode.tests import url
24 from rhodecode.tests import url
25
25
26
26
27 @pytest.mark.usefixtures("app")
27 @pytest.mark.usefixtures("app")
28 class TestChangesetController(object):
28 class TestChangesetController(object):
29
29
30 def test_index(self, backend):
30 def test_index(self, backend):
31 commit_id = self.commit_id[backend.alias]
31 commit_id = self.commit_id[backend.alias]
32 response = self.app.get(url(
32 response = self.app.get(url(
33 controller='changeset', action='index',
33 controller='changeset', action='index',
34 repo_name=backend.repo_name, revision=commit_id))
34 repo_name=backend.repo_name, revision=commit_id))
35 response.mustcontain('Added a symlink')
35 response.mustcontain('Added a symlink')
36 response.mustcontain(commit_id)
36 response.mustcontain(commit_id)
37 response.mustcontain('No newline at end of file')
37 response.mustcontain('No newline at end of file')
38
38
39 def test_index_raw(self, backend):
39 def test_index_raw(self, backend):
40 commit_id = self.commit_id[backend.alias]
40 commit_id = self.commit_id[backend.alias]
41 response = self.app.get(url(
41 response = self.app.get(url(
42 controller='changeset', action='changeset_raw',
42 controller='changeset', action='changeset_raw',
43 repo_name=backend.repo_name, revision=commit_id))
43 repo_name=backend.repo_name, revision=commit_id))
44 assert response.body == self.diffs[backend.alias]
44 assert response.body == self.diffs[backend.alias]
45
45
46 def test_index_raw_patch(self, backend):
46 def test_index_raw_patch(self, backend):
47 response = self.app.get(url(
47 response = self.app.get(url(
48 controller='changeset', action='changeset_patch',
48 controller='changeset', action='changeset_patch',
49 repo_name=backend.repo_name,
49 repo_name=backend.repo_name,
50 revision=self.commit_id[backend.alias]))
50 revision=self.commit_id[backend.alias]))
51 assert response.body == self.patches[backend.alias]
51 assert response.body == self.patches[backend.alias]
52
52
53 def test_index_changeset_download(self, backend):
53 def test_index_changeset_download(self, backend):
54 response = self.app.get(url(
54 response = self.app.get(url(
55 controller='changeset', action='changeset_download',
55 controller='changeset', action='changeset_download',
56 repo_name=backend.repo_name,
56 repo_name=backend.repo_name,
57 revision=self.commit_id[backend.alias]))
57 revision=self.commit_id[backend.alias]))
58 assert response.body == self.diffs[backend.alias]
58 assert response.body == self.diffs[backend.alias]
59
59
60 @pytest.mark.xfail_backends("svn", reason="Depends on consistent diffs")
61 def test_single_commit_page_different_ops(self, backend):
60 def test_single_commit_page_different_ops(self, backend):
62 commit_id = {
61 commit_id = {
63 'hg': '603d6c72c46d953420c89d36372f08d9f305f5dd',
62 'hg': '603d6c72c46d953420c89d36372f08d9f305f5dd',
64 'git': '03fa803d7e9fb14daa9a3089e0d1494eda75d986',
63 'git': '03fa803d7e9fb14daa9a3089e0d1494eda75d986',
65 'svn': '337',
64 'svn': '337',
66 }
65 }
67 commit_id = commit_id[backend.alias]
66 commit_id = commit_id[backend.alias]
68 response = self.app.get(url(
67 response = self.app.get(url(
69 controller='changeset', action='index',
68 controller='changeset', action='index',
70 repo_name=backend.repo_name, revision=commit_id))
69 repo_name=backend.repo_name, revision=commit_id))
71
70
72 response.mustcontain(_shorten_commit_id(commit_id))
71 response.mustcontain(_shorten_commit_id(commit_id))
73 response.mustcontain('21 files changed: 943 inserted, 288 deleted')
72 response.mustcontain('21 files changed: 943 inserted, 288 deleted')
74
73
75 # files op files
74 # files op files
76 response.mustcontain('File no longer present at commit: %s' %
75 response.mustcontain('File no longer present at commit: %s' %
77 _shorten_commit_id(commit_id))
76 _shorten_commit_id(commit_id))
78 response.mustcontain('new file 100644')
77
78 # svn uses a different filename
79 if backend.alias == 'svn':
80 response.mustcontain('new file 10644')
81 else:
82 response.mustcontain('new file 100644')
79 response.mustcontain('Changed theme to ADC theme') # commit msg
83 response.mustcontain('Changed theme to ADC theme') # commit msg
80
84
81 self._check_diff_menus(response, right_menu=True)
85 self._check_diff_menus(response, right_menu=True)
82
86
83 @pytest.mark.xfail_backends("svn", reason="Depends on consistent diffs")
84 def test_commit_range_page_different_ops(self, backend):
87 def test_commit_range_page_different_ops(self, backend):
85 commit_id_range = {
88 commit_id_range = {
86 'hg': (
89 'hg': (
87 '25d7e49c18b159446cadfa506a5cf8ad1cb04067',
90 '25d7e49c18b159446cadfa506a5cf8ad1cb04067',
88 '603d6c72c46d953420c89d36372f08d9f305f5dd'),
91 '603d6c72c46d953420c89d36372f08d9f305f5dd'),
89 'git': (
92 'git': (
90 '6fc9270775aaf5544c1deb014f4ddd60c952fcbb',
93 '6fc9270775aaf5544c1deb014f4ddd60c952fcbb',
91 '03fa803d7e9fb14daa9a3089e0d1494eda75d986'),
94 '03fa803d7e9fb14daa9a3089e0d1494eda75d986'),
92 'svn': (
95 'svn': (
93 '335',
96 '335',
94 '337'),
97 '337'),
95 }
98 }
96 commit_ids = commit_id_range[backend.alias]
99 commit_ids = commit_id_range[backend.alias]
97 commit_id = '%s...%s' % (commit_ids[0], commit_ids[1])
100 commit_id = '%s...%s' % (commit_ids[0], commit_ids[1])
98 response = self.app.get(url(
101 response = self.app.get(url(
99 controller='changeset', action='index',
102 controller='changeset', action='index',
100 repo_name=backend.repo_name, revision=commit_id))
103 repo_name=backend.repo_name, revision=commit_id))
101
104
102 response.mustcontain(_shorten_commit_id(commit_ids[0]))
105 response.mustcontain(_shorten_commit_id(commit_ids[0]))
103 response.mustcontain(_shorten_commit_id(commit_ids[1]))
106 response.mustcontain(_shorten_commit_id(commit_ids[1]))
104 response.mustcontain('33 files changed: 1165 inserted, 308 deleted')
107
108 # svn is special
109 if backend.alias == 'svn':
110 response.mustcontain('new file 10644')
111 response.mustcontain('34 files changed: 1184 inserted, 311 deleted')
112 else:
113 response.mustcontain('new file 100644')
114 response.mustcontain('33 files changed: 1165 inserted, 308 deleted')
105
115
106 # files op files
116 # files op files
107 response.mustcontain('File no longer present at commit: %s' %
117 response.mustcontain('File no longer present at commit: %s' %
108 _shorten_commit_id(commit_ids[1]))
118 _shorten_commit_id(commit_ids[1]))
109 response.mustcontain('new file 100644')
110 response.mustcontain('Added docstrings to vcs.cli') # commit msg
119 response.mustcontain('Added docstrings to vcs.cli') # commit msg
111 response.mustcontain('Changed theme to ADC theme') # commit msg
120 response.mustcontain('Changed theme to ADC theme') # commit msg
112
121
113 self._check_diff_menus(response)
122 self._check_diff_menus(response)
114
123
115 @pytest.mark.xfail_backends("svn", reason="Depends on consistent diffs")
116 def test_combined_compare_commit_page_different_ops(self, backend):
124 def test_combined_compare_commit_page_different_ops(self, backend):
117 commit_id_range = {
125 commit_id_range = {
118 'hg': (
126 'hg': (
119 '4fdd71e9427417b2e904e0464c634fdee85ec5a7',
127 '4fdd71e9427417b2e904e0464c634fdee85ec5a7',
120 '603d6c72c46d953420c89d36372f08d9f305f5dd'),
128 '603d6c72c46d953420c89d36372f08d9f305f5dd'),
121 'git': (
129 'git': (
122 'f5fbf9cfd5f1f1be146f6d3b38bcd791a7480c13',
130 'f5fbf9cfd5f1f1be146f6d3b38bcd791a7480c13',
123 '03fa803d7e9fb14daa9a3089e0d1494eda75d986'),
131 '03fa803d7e9fb14daa9a3089e0d1494eda75d986'),
124 'svn': (
132 'svn': (
125 '335',
133 '335',
126 '337'),
134 '337'),
127 }
135 }
128 commit_ids = commit_id_range[backend.alias]
136 commit_ids = commit_id_range[backend.alias]
129 response = self.app.get(url(
137 response = self.app.get(url(
130 controller='compare', action='compare',
138 controller='compare', action='compare',
131 repo_name=backend.repo_name,
139 repo_name=backend.repo_name,
132 source_ref_type='rev', source_ref=commit_ids[0],
140 source_ref_type='rev', source_ref=commit_ids[0],
133 target_ref_type='rev', target_ref=commit_ids[1], ))
141 target_ref_type='rev', target_ref=commit_ids[1], ))
134
142
135 response.mustcontain(_shorten_commit_id(commit_ids[0]))
143 response.mustcontain(_shorten_commit_id(commit_ids[0]))
136 response.mustcontain(_shorten_commit_id(commit_ids[1]))
144 response.mustcontain(_shorten_commit_id(commit_ids[1]))
137 response.mustcontain('32 files changed: 1165 inserted, 308 deleted')
138
145
139 # files op files
146 # files op files
140 response.mustcontain('File no longer present at commit: %s' %
147 response.mustcontain('File no longer present at commit: %s' %
141 _shorten_commit_id(commit_ids[1]))
148 _shorten_commit_id(commit_ids[1]))
142 response.mustcontain('new file 100644')
149
150 # svn is special
151 if backend.alias == 'svn':
152 response.mustcontain('new file 10644')
153 response.mustcontain('32 files changed: 1179 inserted, 310 deleted')
154 else:
155 response.mustcontain('new file 100644')
156 response.mustcontain('32 files changed: 1165 inserted, 308 deleted')
157
143 response.mustcontain('Added docstrings to vcs.cli') # commit msg
158 response.mustcontain('Added docstrings to vcs.cli') # commit msg
144 response.mustcontain('Changed theme to ADC theme') # commit msg
159 response.mustcontain('Changed theme to ADC theme') # commit msg
145
160
146 self._check_diff_menus(response)
161 self._check_diff_menus(response)
147
162
148 def test_changeset_range(self, backend):
163 def test_changeset_range(self, backend):
149 self._check_changeset_range(
164 self._check_changeset_range(
150 backend, self.commit_id_range, self.commit_id_range_result)
165 backend, self.commit_id_range, self.commit_id_range_result)
151
166
152 def test_changeset_range_with_initial_commit(self, backend):
167 def test_changeset_range_with_initial_commit(self, backend):
153 commit_id_range = {
168 commit_id_range = {
154 'hg': (
169 'hg': (
155 'b986218ba1c9b0d6a259fac9b050b1724ed8e545'
170 'b986218ba1c9b0d6a259fac9b050b1724ed8e545'
156 '...6cba7170863a2411822803fa77a0a264f1310b35'),
171 '...6cba7170863a2411822803fa77a0a264f1310b35'),
157 'git': (
172 'git': (
158 'c1214f7e79e02fc37156ff215cd71275450cffc3'
173 'c1214f7e79e02fc37156ff215cd71275450cffc3'
159 '...fa6600f6848800641328adbf7811fd2372c02ab2'),
174 '...fa6600f6848800641328adbf7811fd2372c02ab2'),
160 'svn': '1...3',
175 'svn': '1...3',
161 }
176 }
162 commit_id_range_result = {
177 commit_id_range_result = {
163 'hg': ['b986218ba1c9', '3d8f361e72ab', '6cba7170863a'],
178 'hg': ['b986218ba1c9', '3d8f361e72ab', '6cba7170863a'],
164 'git': ['c1214f7e79e0', '38b5fe81f109', 'fa6600f68488'],
179 'git': ['c1214f7e79e0', '38b5fe81f109', 'fa6600f68488'],
165 'svn': ['1', '2', '3'],
180 'svn': ['1', '2', '3'],
166 }
181 }
167 self._check_changeset_range(
182 self._check_changeset_range(
168 backend, commit_id_range, commit_id_range_result)
183 backend, commit_id_range, commit_id_range_result)
169
184
170 def _check_changeset_range(
185 def _check_changeset_range(
171 self, backend, commit_id_ranges, commit_id_range_result):
186 self, backend, commit_id_ranges, commit_id_range_result):
172 response = self.app.get(
187 response = self.app.get(
173 url(controller='changeset', action='index',
188 url(controller='changeset', action='index',
174 repo_name=backend.repo_name,
189 repo_name=backend.repo_name,
175 revision=commit_id_ranges[backend.alias]))
190 revision=commit_id_ranges[backend.alias]))
176 expected_result = commit_id_range_result[backend.alias]
191 expected_result = commit_id_range_result[backend.alias]
177 response.mustcontain('{} commits'.format(len(expected_result)))
192 response.mustcontain('{} commits'.format(len(expected_result)))
178 for commit_id in expected_result:
193 for commit_id in expected_result:
179 response.mustcontain(commit_id)
194 response.mustcontain(commit_id)
180
195
181 commit_id = {
196 commit_id = {
182 'hg': '2062ec7beeeaf9f44a1c25c41479565040b930b2',
197 'hg': '2062ec7beeeaf9f44a1c25c41479565040b930b2',
183 'svn': '393',
198 'svn': '393',
184 'git': 'fd627b9e0dd80b47be81af07c4a98518244ed2f7',
199 'git': 'fd627b9e0dd80b47be81af07c4a98518244ed2f7',
185 }
200 }
186
201
187 commit_id_range = {
202 commit_id_range = {
188 'hg': (
203 'hg': (
189 'a53d9201d4bc278910d416d94941b7ea007ecd52'
204 'a53d9201d4bc278910d416d94941b7ea007ecd52'
190 '...2062ec7beeeaf9f44a1c25c41479565040b930b2'),
205 '...2062ec7beeeaf9f44a1c25c41479565040b930b2'),
191 'git': (
206 'git': (
192 '7ab37bc680b4aa72c34d07b230c866c28e9fc204'
207 '7ab37bc680b4aa72c34d07b230c866c28e9fc204'
193 '...fd627b9e0dd80b47be81af07c4a98518244ed2f7'),
208 '...fd627b9e0dd80b47be81af07c4a98518244ed2f7'),
194 'svn': '391...393',
209 'svn': '391...393',
195 }
210 }
196
211
197 commit_id_range_result = {
212 commit_id_range_result = {
198 'hg': ['a53d9201d4bc', '96507bd11ecc', '2062ec7beeea'],
213 'hg': ['a53d9201d4bc', '96507bd11ecc', '2062ec7beeea'],
199 'git': ['7ab37bc680b4', '5f2c6ee19592', 'fd627b9e0dd8'],
214 'git': ['7ab37bc680b4', '5f2c6ee19592', 'fd627b9e0dd8'],
200 'svn': ['391', '392', '393'],
215 'svn': ['391', '392', '393'],
201 }
216 }
202
217
203 diffs = {
218 diffs = {
204 'hg': r"""diff --git a/README b/README
219 'hg': r"""diff --git a/README b/README
205 new file mode 120000
220 new file mode 120000
206 --- /dev/null
221 --- /dev/null
207 +++ b/README
222 +++ b/README
208 @@ -0,0 +1,1 @@
223 @@ -0,0 +1,1 @@
209 +README.rst
224 +README.rst
210 \ No newline at end of file
225 \ No newline at end of file
211 """,
226 """,
212 'git': r"""diff --git a/README b/README
227 'git': r"""diff --git a/README b/README
213 new file mode 120000
228 new file mode 120000
214 index 0000000000000000000000000000000000000000..92cacd285355271487b7e379dba6ca60f9a554a4
229 index 0000000000000000000000000000000000000000..92cacd285355271487b7e379dba6ca60f9a554a4
215 --- /dev/null
230 --- /dev/null
216 +++ b/README
231 +++ b/README
217 @@ -0,0 +1 @@
232 @@ -0,0 +1 @@
218 +README.rst
233 +README.rst
219 \ No newline at end of file
234 \ No newline at end of file
220 """,
235 """,
221 'svn': """Index: README
236 'svn': """Index: README
222 ===================================================================
237 ===================================================================
223 diff --git a/README b/README
238 diff --git a/README b/README
224 new file mode 10644
239 new file mode 10644
225 --- /dev/null\t(revision 0)
240 --- /dev/null\t(revision 0)
226 +++ b/README\t(revision 393)
241 +++ b/README\t(revision 393)
227 @@ -0,0 +1 @@
242 @@ -0,0 +1 @@
228 +link README.rst
243 +link README.rst
229 \\ No newline at end of file
244 \\ No newline at end of file
230 """,
245 """,
231 }
246 }
232
247
233 patches = {
248 patches = {
234 'hg': r"""# HG changeset patch
249 'hg': r"""# HG changeset patch
235 # User Marcin Kuzminski <marcin@python-works.com>
250 # User Marcin Kuzminski <marcin@python-works.com>
236 # Date 2014-01-07 12:21:40
251 # Date 2014-01-07 12:21:40
237 # Node ID 2062ec7beeeaf9f44a1c25c41479565040b930b2
252 # Node ID 2062ec7beeeaf9f44a1c25c41479565040b930b2
238 # Parent 96507bd11ecc815ebc6270fdf6db110928c09c1e
253 # Parent 96507bd11ecc815ebc6270fdf6db110928c09c1e
239
254
240 Added a symlink
255 Added a symlink
241
256
242 """ + diffs['hg'],
257 """ + diffs['hg'],
243 'git': r"""From fd627b9e0dd80b47be81af07c4a98518244ed2f7 2014-01-07 12:22:20
258 'git': r"""From fd627b9e0dd80b47be81af07c4a98518244ed2f7 2014-01-07 12:22:20
244 From: Marcin Kuzminski <marcin@python-works.com>
259 From: Marcin Kuzminski <marcin@python-works.com>
245 Date: 2014-01-07 12:22:20
260 Date: 2014-01-07 12:22:20
246 Subject: [PATCH] Added a symlink
261 Subject: [PATCH] Added a symlink
247
262
248 ---
263 ---
249
264
250 """ + diffs['git'],
265 """ + diffs['git'],
251 'svn': r"""# SVN changeset patch
266 'svn': r"""# SVN changeset patch
252 # User marcin
267 # User marcin
253 # Date 2014-09-02 12:25:22.071142
268 # Date 2014-09-02 12:25:22.071142
254 # Revision 393
269 # Revision 393
255
270
256 Added a symlink
271 Added a symlink
257
272
258 """ + diffs['svn'],
273 """ + diffs['svn'],
259 }
274 }
260
275
261 def _check_diff_menus(self, response, right_menu=False):
276 def _check_diff_menus(self, response, right_menu=False):
262 # diff menus
277 # diff menus
263 for elem in ['Show File', 'Unified Diff', 'Side-by-side Diff',
278 for elem in ['Show File', 'Unified Diff', 'Side-by-side Diff',
264 'Raw Diff', 'Download Diff']:
279 'Raw Diff', 'Download Diff']:
265 response.mustcontain(elem)
280 response.mustcontain(elem)
266
281
267 # right pane diff menus
282 # right pane diff menus
268 if right_menu:
283 if right_menu:
269 for elem in ['Ignore whitespace', 'Increase context',
284 for elem in ['Ignore whitespace', 'Increase context',
270 'Hide comments']:
285 'Hide comments']:
271 response.mustcontain(elem)
286 response.mustcontain(elem)
General Comments 0
You need to be logged in to leave comments. Login now