Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
d9213d09
Kaydet (Commit)
d9213d09
authored
Kas 01, 2012
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #16678 -- Wrote tests for contrib.redirects app
Thanks Julien Phalip for the report.
üst
ede8a0be
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
tests.py
django/contrib/redirects/tests.py
+42
-0
No files found.
django/contrib/redirects/tests.py
0 → 100644
Dosyayı görüntüle @
d9213d09
from
django.conf
import
settings
from
django.contrib.sites.models
import
Site
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
django.utils
import
six
from
.models
import
Redirect
@override_settings
(
SITE_ID
=
1
,
APPEND_SLASH
=
True
,
MIDDLEWARE_CLASSES
=
list
(
settings
.
MIDDLEWARE_CLASSES
)
+
[
'django.contrib.redirects.middleware.RedirectFallbackMiddleware'
],
)
class
RedirectTests
(
TestCase
):
def
setUp
(
self
):
self
.
site
=
Site
.
objects
.
get
(
pk
=
settings
.
SITE_ID
)
def
test_model
(
self
):
r1
=
Redirect
.
objects
.
create
(
site
=
self
.
site
,
old_path
=
'/initial'
,
new_path
=
'/new_target'
)
self
.
assertEqual
(
six
.
text_type
(
r1
),
"/initial ---> /new_target"
)
def
test_redirect_middleware
(
self
):
r1
=
Redirect
.
objects
.
create
(
site
=
self
.
site
,
old_path
=
'/initial'
,
new_path
=
'/new_target'
)
response
=
self
.
client
.
get
(
'/initial'
)
self
.
assertRedirects
(
response
,
'/new_target'
,
status_code
=
301
,
target_status_code
=
404
)
# Works also with trailing slash
response
=
self
.
client
.
get
(
'/initial/'
)
self
.
assertRedirects
(
response
,
'/new_target'
,
status_code
=
301
,
target_status_code
=
404
)
def
test_response_gone
(
self
):
"""When the redirect target is '', return a 410"""
r1
=
Redirect
.
objects
.
create
(
site
=
self
.
site
,
old_path
=
'/initial'
,
new_path
=
''
)
response
=
self
.
client
.
get
(
'/initial'
)
self
.
assertEqual
(
response
.
status_code
,
410
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment