4
4
from django .test import TestCase
5
5
from django .test .utils import override_settings
6
6
from django_dynamic_fixture import fixture , get
7
- from mock import patch
8
7
9
8
from readthedocs .builds .constants import LATEST
10
9
from readthedocs .builds .models import Version
@@ -19,21 +18,6 @@ class RedirectTests(TestCase):
19
18
def setUp (self ):
20
19
logging .disable (logging .DEBUG )
21
20
self .client .login (username = 'eric' , password = 'test' )
22
- self .client .post (
23
- '/dashboard/import/' ,
24
- {
25
- 'repo_type' : 'git' , 'name' : 'Pip' ,
26
- 'tags' : 'big, fucking, monkey' , 'default_branch' : '' ,
27
- 'project_url' : 'http://pip.rtfd.org' ,
28
- 'repo' : 'https://github.com/fail/sauce' ,
29
- 'csrfmiddlewaretoken' : '34af7c8a5ba84b84564403a280d9a9be' ,
30
- 'default_version' : LATEST ,
31
- 'privacy_level' : 'public' ,
32
- 'version_privacy_level' : 'public' ,
33
- 'description' : 'wat' ,
34
- 'documentation_type' : 'sphinx' ,
35
- },
36
- )
37
21
pip = Project .objects .get (slug = 'pip' )
38
22
pip .versions .create_latest ()
39
23
@@ -135,21 +119,6 @@ class RedirectAppTests(TestCase):
135
119
136
120
def setUp (self ):
137
121
self .client .login (username = 'eric' , password = 'test' )
138
- self .client .post (
139
- '/dashboard/import/' ,
140
- {
141
- 'repo_type' : 'git' , 'name' : 'Pip' ,
142
- 'tags' : 'big, fucking, monkey' , 'default_branch' : '' ,
143
- 'project_url' : 'http://pip.rtfd.org' ,
144
- 'repo' : 'https://github.com/fail/sauce' ,
145
- 'csrfmiddlewaretoken' : '34af7c8a5ba84b84564403a280d9a9be' ,
146
- 'default_version' : LATEST ,
147
- 'privacy_level' : 'public' ,
148
- 'version_privacy_level' : 'public' ,
149
- 'description' : 'wat' ,
150
- 'documentation_type' : 'sphinx' ,
151
- },
152
- )
153
122
self .pip = Project .objects .get (slug = 'pip' )
154
123
self .pip .versions .create_latest ()
155
124
@@ -398,35 +367,33 @@ def test_redirect_keeps_version_number(self):
398
367
project = self .pip , redirect_type = 'page' ,
399
368
from_url = '/how_to_install.html' , to_url = '/install.html' ,
400
369
)
401
- with patch ('readthedocs.core.views.serve._serve_symlink_docs' ) as _serve_docs :
402
- _serve_docs .side_effect = Http404 ()
403
- r = self .client .get (
404
- '/en/0.8.1/how_to_install.html' ,
405
- HTTP_HOST = 'pip.readthedocs.org' ,
406
- )
407
- self .assertEqual (r .status_code , 302 )
408
- self .assertEqual (
409
- r ['Location' ],
410
- 'http://pip.readthedocs.org/en/0.8.1/install.html' ,
411
- )
370
+ r = self .client .get (
371
+ '/en/0.8.2/how_to_install.html' ,
372
+ HTTP_HOST = 'pip.readthedocs.org' ,
373
+ )
374
+ self .assertEqual (r .status_code , 302 )
375
+ self .assertEqual (
376
+ r ['Location' ],
377
+ 'http://pip.readthedocs.org/en/0.8.2/install.html' ,
378
+ )
412
379
413
380
@override_settings (USE_SUBDOMAIN = True )
414
381
def test_redirect_keeps_language (self ):
382
+ self .pip .language = 'de'
383
+ self .pip .save ()
415
384
Redirect .objects .create (
416
385
project = self .pip , redirect_type = 'page' ,
417
386
from_url = '/how_to_install.html' , to_url = '/install.html' ,
418
387
)
419
- with patch ('readthedocs.core.views.serve._serve_symlink_docs' ) as _serve_docs :
420
- _serve_docs .side_effect = Http404 ()
421
- r = self .client .get (
422
- '/de/0.8.1/how_to_install.html' ,
423
- HTTP_HOST = 'pip.readthedocs.org' ,
424
- )
425
- self .assertEqual (r .status_code , 302 )
426
- self .assertEqual (
427
- r ['Location' ],
428
- 'http://pip.readthedocs.org/de/0.8.1/install.html' ,
429
- )
388
+ r = self .client .get (
389
+ '/de/0.8.2/how_to_install.html' ,
390
+ HTTP_HOST = 'pip.readthedocs.org' ,
391
+ )
392
+ self .assertEqual (r .status_code , 302 )
393
+ self .assertEqual (
394
+ r ['Location' ],
395
+ 'http://pip.readthedocs.org/de/0.8.2/install.html' ,
396
+ )
430
397
431
398
@override_settings (USE_SUBDOMAIN = True )
432
399
def test_redirect_recognizes_custom_cname (self ):
0 commit comments