##// END OF EJS Templates
fixed test after last fixes
marcink -
r2085:2678b1e0 beta
parent child Browse files
Show More
@@ -1,318 +1,314
1 1 from rhodecode.tests import *
2 2
3 3 ARCHIVE_SPECS = {
4 4 '.tar.bz2': ('application/x-bzip2', 'tbz2', ''),
5 5 '.tar.gz': ('application/x-gzip', 'tgz', ''),
6 6 '.zip': ('application/zip', 'zip', ''),
7 7 }
8 8
9 9
10 10 class TestFilesController(TestController):
11 11
12 12 def test_index(self):
13 13 self.log_user()
14 14 response = self.app.get(url(controller='files', action='index',
15 15 repo_name=HG_REPO,
16 16 revision='tip',
17 17 f_path='/'))
18 18 # Test response...
19 19 response.mustcontain('<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/docs">docs</a>')
20 20 response.mustcontain('<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/tests">tests</a>')
21 21 response.mustcontain('<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/vcs">vcs</a>')
22 22 response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/.hgignore">.hgignore</a>')
23 23 response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/MANIFEST.in">MANIFEST.in</a>')
24 24
25 25 def test_index_revision(self):
26 26 self.log_user()
27 27
28 28 response = self.app.get(
29 29 url(controller='files', action='index',
30 30 repo_name=HG_REPO,
31 31 revision='7ba66bec8d6dbba14a2155be32408c435c5f4492',
32 32 f_path='/')
33 33 )
34 34
35 35 #Test response...
36 36
37 37 response.mustcontain('<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/docs">docs</a>')
38 38 response.mustcontain('<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/tests">tests</a>')
39 39 response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/README.rst">README.rst</a>')
40 40 response.mustcontain('1.1 KiB')
41 41 response.mustcontain('text/x-python')
42 42
43 43 def test_index_different_branch(self):
44 44 self.log_user()
45 45
46 46 response = self.app.get(url(controller='files', action='index',
47 47 repo_name=HG_REPO,
48 48 revision='97e8b885c04894463c51898e14387d80c30ed1ee',
49 49 f_path='/'))
50 50
51 51 response.mustcontain("""<span style="text-transform: uppercase;"><a href="#">branch: git</a></span>""")
52 52
53 53 def test_index_paging(self):
54 54 self.log_user()
55 55
56 56 for r in [(73, 'a066b25d5df7016b45a41b7e2a78c33b57adc235'),
57 57 (92, 'cc66b61b8455b264a7a8a2d8ddc80fcfc58c221e'),
58 58 (109, '75feb4c33e81186c87eac740cee2447330288412'),
59 59 (1, '3d8f361e72ab303da48d799ff1ac40d5ac37c67e'),
60 60 (0, 'b986218ba1c9b0d6a259fac9b050b1724ed8e545')]:
61 61
62 62 response = self.app.get(url(controller='files', action='index',
63 63 repo_name=HG_REPO,
64 64 revision=r[1],
65 65 f_path='/'))
66 66
67 67 response.mustcontain("""@ r%s:%s""" % (r[0], r[1][:12]))
68 68
69 69 def test_file_source(self):
70 70 self.log_user()
71 71 response = self.app.get(url(controller='files', action='index',
72 72 repo_name=HG_REPO,
73 73 revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc',
74 74 f_path='vcs/nodes.py'))
75 75
76 76 #test or history
77 77 response.mustcontain("""<optgroup label="Changesets">
78 <option selected="selected" value="8911406ad776fdd3d0b9932a2e89677e57405a48">r167:8911406ad776 (default)</option>
78 <option value="8911406ad776fdd3d0b9932a2e89677e57405a48">r167:8911406ad776 (default)</option>
79 79 <option value="aa957ed78c35a1541f508d2ec90e501b0a9e3167">r165:aa957ed78c35 (default)</option>
80 80 <option value="48e11b73e94c0db33e736eaeea692f990cb0b5f1">r140:48e11b73e94c (default)</option>
81 81 <option value="adf3cbf483298563b968a6c673cd5bde5f7d5eea">r126:adf3cbf48329 (default)</option>
82 82 <option value="6249fd0fb2cfb1411e764129f598e2cf0de79a6f">r113:6249fd0fb2cf (git)</option>
83 83 <option value="75feb4c33e81186c87eac740cee2447330288412">r109:75feb4c33e81 (default)</option>
84 84 <option value="9a4dc232ecdc763ef2e98ae2238cfcbba4f6ad8d">r108:9a4dc232ecdc (default)</option>
85 85 <option value="595cce4efa21fda2f2e4eeb4fe5f2a6befe6fa2d">r107:595cce4efa21 (default)</option>
86 86 <option value="4a8bd421fbc2dfbfb70d85a3fe064075ab2c49da">r104:4a8bd421fbc2 (default)</option>
87 87 <option value="57be63fc8f85e65a0106a53187f7316f8c487ffa">r102:57be63fc8f85 (default)</option>
88 88 <option value="5530bd87f7e2e124a64d07cb2654c997682128be">r101:5530bd87f7e2 (git)</option>
89 89 <option value="e516008b1c93f142263dc4b7961787cbad654ce1">r99:e516008b1c93 (default)</option>
90 90 <option value="41f43fc74b8b285984554532eb105ac3be5c434f">r93:41f43fc74b8b (default)</option>
91 91 <option value="cc66b61b8455b264a7a8a2d8ddc80fcfc58c221e">r92:cc66b61b8455 (default)</option>
92 92 <option value="73ab5b616b3271b0518682fb4988ce421de8099f">r91:73ab5b616b32 (default)</option>
93 93 <option value="e0da75f308c0f18f98e9ce6257626009fdda2b39">r82:e0da75f308c0 (default)</option>
94 94 <option value="fb2e41e0f0810be4d7103bc2a4c7be16ee3ec611">r81:fb2e41e0f081 (default)</option>
95 95 <option value="602ae2f5e7ade70b3b66a58cdd9e3e613dc8a028">r76:602ae2f5e7ad (default)</option>
96 96 <option value="a066b25d5df7016b45a41b7e2a78c33b57adc235">r73:a066b25d5df7 (default)</option>
97 97 <option value="637a933c905958ce5151f154147c25c1c7b68832">r61:637a933c9059 (web)</option>
98 98 <option value="0c21004effeb8ce2d2d5b4a8baf6afa8394b6fbc">r60:0c21004effeb (web)</option>
99 99 <option value="a1f39c56d3f1d52d5fb5920370a2a2716cd9a444">r59:a1f39c56d3f1 (web)</option>
100 100 <option value="97d32df05c715a3bbf936bf3cc4e32fb77fe1a7f">r58:97d32df05c71 (web)</option>
101 101 <option value="08eaf14517718dccea4b67755a93368341aca919">r57:08eaf1451771 (web)</option>
102 102 <option value="22f71ad265265a53238359c883aa976e725aa07d">r56:22f71ad26526 (web)</option>
103 103 <option value="97501f02b7b4330924b647755663a2d90a5e638d">r49:97501f02b7b4 (web)</option>
104 104 <option value="86ede6754f2b27309452bb11f997386ae01d0e5a">r47:86ede6754f2b (web)</option>
105 105 <option value="014c40c0203c423dc19ecf94644f7cac9d4cdce0">r45:014c40c0203c (web)</option>
106 106 <option value="ee87846a61c12153b51543bf860e1026c6d3dcba">r30:ee87846a61c1 (default)</option>
107 107 <option value="9bb326a04ae5d98d437dece54be04f830cf1edd9">r26:9bb326a04ae5 (default)</option>
108 108 <option value="536c1a19428381cfea92ac44985304f6a8049569">r24:536c1a194283 (default)</option>
109 109 <option value="dc5d2c0661b61928834a785d3e64a3f80d3aad9c">r8:dc5d2c0661b6 (default)</option>
110 110 <option value="3803844fdbd3b711175fc3da9bdacfcd6d29a6fb">r7:3803844fdbd3 (default)</option>
111 111 </optgroup>
112 112 <optgroup label="Branches">
113 <option value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">default</option>
113 <option selected="selected" value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">default</option>
114 114 <option value="97e8b885c04894463c51898e14387d80c30ed1ee">git</option>
115 115 <option value="2e6a2bf9356ca56df08807f4ad86d480da72a8f4">web</option>
116 116 </optgroup>
117 117 <optgroup label="Tags">
118 <option value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">tip</option>
118 <option selected="selected" value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">tip</option>
119 119 <option value="fd4bdb5e9b2a29b4393a4ac6caef48c17ee1a200">0.1.4</option>
120 120 <option value="17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">0.1.3</option>
121 121 <option value="a7e60bff65d57ac3a1a1ce3b12a70f8a9e8a7720">0.1.2</option>
122 122 <option value="eb3a60fc964309c1a318b8dfe26aa2d1586c85ae">0.1.1</option>
123 </optgroup>""")
123 </optgroup>
124 """)
124 125
125 response.mustcontain("""<div class="commit">Partially implemented #16. filecontent/commit message/author/node name are safe_unicode now.
126 In addition some other __str__ are unicode as well
127 Added test for unicode
128 Improved test to clone into uniq repository.
129 removed extra unicode conversion in diff.</div>""")
126 response.mustcontain("""<div class="commit">merge</div>""")
130 127
131 128 response.mustcontain("""<span style="text-transform: uppercase;"><a href="#">branch: default</a></span>""")
132 129
133 130 def test_file_annotation(self):
134 131 self.log_user()
135 132 response = self.app.get(url(controller='files', action='annotate',
136 133 repo_name=HG_REPO,
137 134 revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc',
138 135 f_path='vcs/nodes.py'))
139 136
140 137
141 138 response.mustcontain("""<optgroup label="Changesets">
142 <option selected="selected" value="8911406ad776fdd3d0b9932a2e89677e57405a48">r167:8911406ad776 (default)</option>
139 <option value="8911406ad776fdd3d0b9932a2e89677e57405a48">r167:8911406ad776 (default)</option>
143 140 <option value="aa957ed78c35a1541f508d2ec90e501b0a9e3167">r165:aa957ed78c35 (default)</option>
144 141 <option value="48e11b73e94c0db33e736eaeea692f990cb0b5f1">r140:48e11b73e94c (default)</option>
145 142 <option value="adf3cbf483298563b968a6c673cd5bde5f7d5eea">r126:adf3cbf48329 (default)</option>
146 143 <option value="6249fd0fb2cfb1411e764129f598e2cf0de79a6f">r113:6249fd0fb2cf (git)</option>
147 144 <option value="75feb4c33e81186c87eac740cee2447330288412">r109:75feb4c33e81 (default)</option>
148 145 <option value="9a4dc232ecdc763ef2e98ae2238cfcbba4f6ad8d">r108:9a4dc232ecdc (default)</option>
149 146 <option value="595cce4efa21fda2f2e4eeb4fe5f2a6befe6fa2d">r107:595cce4efa21 (default)</option>
150 147 <option value="4a8bd421fbc2dfbfb70d85a3fe064075ab2c49da">r104:4a8bd421fbc2 (default)</option>
151 148 <option value="57be63fc8f85e65a0106a53187f7316f8c487ffa">r102:57be63fc8f85 (default)</option>
152 149 <option value="5530bd87f7e2e124a64d07cb2654c997682128be">r101:5530bd87f7e2 (git)</option>
153 150 <option value="e516008b1c93f142263dc4b7961787cbad654ce1">r99:e516008b1c93 (default)</option>
154 151 <option value="41f43fc74b8b285984554532eb105ac3be5c434f">r93:41f43fc74b8b (default)</option>
155 152 <option value="cc66b61b8455b264a7a8a2d8ddc80fcfc58c221e">r92:cc66b61b8455 (default)</option>
156 153 <option value="73ab5b616b3271b0518682fb4988ce421de8099f">r91:73ab5b616b32 (default)</option>
157 154 <option value="e0da75f308c0f18f98e9ce6257626009fdda2b39">r82:e0da75f308c0 (default)</option>
158 155 <option value="fb2e41e0f0810be4d7103bc2a4c7be16ee3ec611">r81:fb2e41e0f081 (default)</option>
159 156 <option value="602ae2f5e7ade70b3b66a58cdd9e3e613dc8a028">r76:602ae2f5e7ad (default)</option>
160 157 <option value="a066b25d5df7016b45a41b7e2a78c33b57adc235">r73:a066b25d5df7 (default)</option>
161 158 <option value="637a933c905958ce5151f154147c25c1c7b68832">r61:637a933c9059 (web)</option>
162 159 <option value="0c21004effeb8ce2d2d5b4a8baf6afa8394b6fbc">r60:0c21004effeb (web)</option>
163 160 <option value="a1f39c56d3f1d52d5fb5920370a2a2716cd9a444">r59:a1f39c56d3f1 (web)</option>
164 161 <option value="97d32df05c715a3bbf936bf3cc4e32fb77fe1a7f">r58:97d32df05c71 (web)</option>
165 162 <option value="08eaf14517718dccea4b67755a93368341aca919">r57:08eaf1451771 (web)</option>
166 163 <option value="22f71ad265265a53238359c883aa976e725aa07d">r56:22f71ad26526 (web)</option>
167 164 <option value="97501f02b7b4330924b647755663a2d90a5e638d">r49:97501f02b7b4 (web)</option>
168 165 <option value="86ede6754f2b27309452bb11f997386ae01d0e5a">r47:86ede6754f2b (web)</option>
169 166 <option value="014c40c0203c423dc19ecf94644f7cac9d4cdce0">r45:014c40c0203c (web)</option>
170 167 <option value="ee87846a61c12153b51543bf860e1026c6d3dcba">r30:ee87846a61c1 (default)</option>
171 168 <option value="9bb326a04ae5d98d437dece54be04f830cf1edd9">r26:9bb326a04ae5 (default)</option>
172 169 <option value="536c1a19428381cfea92ac44985304f6a8049569">r24:536c1a194283 (default)</option>
173 170 <option value="dc5d2c0661b61928834a785d3e64a3f80d3aad9c">r8:dc5d2c0661b6 (default)</option>
174 171 <option value="3803844fdbd3b711175fc3da9bdacfcd6d29a6fb">r7:3803844fdbd3 (default)</option>
175 172 </optgroup>
176 173 <optgroup label="Branches">
177 <option value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">default</option>
174 <option selected="selected" value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">default</option>
178 175 <option value="97e8b885c04894463c51898e14387d80c30ed1ee">git</option>
179 176 <option value="2e6a2bf9356ca56df08807f4ad86d480da72a8f4">web</option>
180 177 </optgroup>
181 178 <optgroup label="Tags">
182 <option value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">tip</option>
179 <option selected="selected" value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">tip</option>
183 180 <option value="fd4bdb5e9b2a29b4393a4ac6caef48c17ee1a200">0.1.4</option>
184 181 <option value="17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">0.1.3</option>
185 182 <option value="a7e60bff65d57ac3a1a1ce3b12a70f8a9e8a7720">0.1.2</option>
186 183 <option value="eb3a60fc964309c1a318b8dfe26aa2d1586c85ae">0.1.1</option>
187 </optgroup>
188 """)
184 </optgroup>""")
189 185
190 186 response.mustcontain("""<span style="text-transform: uppercase;"><a href="#">branch: default</a></span>""")
191 187
192 188 def test_archival(self):
193 189 self.log_user()
194 190
195 191 for arch_ext, info in ARCHIVE_SPECS.items():
196 192 fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext
197 193 filename = '%s-%s' % (HG_REPO, fname)
198 194
199 195 response = self.app.get(url(controller='files', action='archivefile',
200 196 repo_name=HG_REPO,
201 197 fname=fname))
202 198
203 199 assert response.status == '200 OK', 'wrong response code'
204 200 assert response.response._headers.items() == [('Pragma', 'no-cache'),
205 201 ('Cache-Control', 'no-cache'),
206 202 ('Content-Type', '%s; charset=utf-8' % info[0]),
207 203 ('Content-Disposition', 'attachment; filename=%s' % filename), ], 'wrong headers'
208 204
209 205 def test_archival_wrong_ext(self):
210 206 self.log_user()
211 207
212 208 for arch_ext in ['tar', 'rar', 'x', '..ax', '.zipz']:
213 209 fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext
214 210
215 211 response = self.app.get(url(controller='files', action='archivefile',
216 212 repo_name=HG_REPO,
217 213 fname=fname))
218 214 assert 'Unknown archive type' in response.body
219 215
220 216
221 217 def test_archival_wrong_revision(self):
222 218 self.log_user()
223 219
224 220 for rev in ['00x000000', 'tar', 'wrong', '@##$@$424213232', '232dffcd']:
225 221 fname = '%s.zip' % rev
226 222
227 223 response = self.app.get(url(controller='files', action='archivefile',
228 224 repo_name=HG_REPO,
229 225 fname=fname))
230 226 assert 'Unknown revision' in response.body
231 227
232 228 #==========================================================================
233 229 # RAW FILE
234 230 #==========================================================================
235 231 def test_raw_file_ok(self):
236 232 self.log_user()
237 233 response = self.app.get(url(controller='files', action='rawfile',
238 234 repo_name=HG_REPO,
239 235 revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc',
240 236 f_path='vcs/nodes.py'))
241 237
242 238 assert response.content_disposition == "attachment; filename=nodes.py"
243 239 assert response.content_type == "text/x-python"
244 240
245 241 def test_raw_file_wrong_cs(self):
246 242 self.log_user()
247 243 rev = u'ERRORce30c96924232dffcd24178a07ffeb5dfc'
248 244 f_path = 'vcs/nodes.py'
249 245
250 246 response = self.app.get(url(controller='files', action='rawfile',
251 247 repo_name=HG_REPO,
252 248 revision=rev,
253 249 f_path=f_path))
254 250
255 251 msg = """Revision %r does not exist for this repository""" % (rev)
256 252 self.checkSessionFlash(response, msg)
257 253
258 254 msg = """%s""" % (HG_REPO)
259 255 self.checkSessionFlash(response, msg)
260 256
261 257 def test_raw_file_wrong_f_path(self):
262 258 self.log_user()
263 259 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
264 260 f_path = 'vcs/ERRORnodes.py'
265 261 response = self.app.get(url(controller='files', action='rawfile',
266 262 repo_name=HG_REPO,
267 263 revision=rev,
268 264 f_path=f_path))
269 265
270 266 msg = "There is no file nor directory at the given path: %r at revision %r" % (f_path, rev[:12])
271 267 self.checkSessionFlash(response, msg)
272 268
273 269 #==========================================================================
274 270 # RAW RESPONSE - PLAIN
275 271 #==========================================================================
276 272 def test_raw_ok(self):
277 273 self.log_user()
278 274 response = self.app.get(url(controller='files', action='raw',
279 275 repo_name=HG_REPO,
280 276 revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc',
281 277 f_path='vcs/nodes.py'))
282 278
283 279 assert response.content_type == "text/plain"
284 280
285 281 def test_raw_wrong_cs(self):
286 282 self.log_user()
287 283 rev = u'ERRORcce30c96924232dffcd24178a07ffeb5dfc'
288 284 f_path = 'vcs/nodes.py'
289 285
290 286 response = self.app.get(url(controller='files', action='raw',
291 287 repo_name=HG_REPO,
292 288 revision=rev,
293 289 f_path=f_path))
294 290 msg = """Revision %r does not exist for this repository""" % (rev)
295 291 self.checkSessionFlash(response, msg)
296 292
297 293 msg = """%s""" % (HG_REPO)
298 294 self.checkSessionFlash(response, msg)
299 295
300 296 def test_raw_wrong_f_path(self):
301 297 self.log_user()
302 298 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
303 299 f_path = 'vcs/ERRORnodes.py'
304 300 response = self.app.get(url(controller='files', action='raw',
305 301 repo_name=HG_REPO,
306 302 revision=rev,
307 303 f_path=f_path))
308 304 msg = "There is no file nor directory at the given path: %r at revision %r" % (f_path, rev[:12])
309 305 self.checkSessionFlash(response, msg)
310 306
311 307 def test_ajaxed_files_list(self):
312 308 self.log_user()
313 309 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
314 310 response = self.app.get(
315 311 url('files_nodelist_home', repo_name=HG_REPO,f_path='/',revision=rev),
316 312 extra_environ={'HTTP_X_PARTIAL_XHR': '1'},
317 313 )
318 314 response.mustcontain("vcs/web/simplevcs/views/repository.py")
General Comments 0
You need to be logged in to leave comments. Login now