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