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
37c93187
Kaydet (Commit)
37c93187
authored
Agu 14, 2012
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[py3] Fixed sitemaps tests.
üst
f2fe7a3e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
24 deletions
+37
-24
generic.py
django/contrib/sitemaps/tests/generic.py
+3
-2
http.py
django/contrib/sitemaps/tests/http.py
+22
-14
https.py
django/contrib/sitemaps/tests/https.py
+12
-8
No files found.
django/contrib/sitemaps/tests/generic.py
Dosyayı görüntüle @
37c93187
...
...
@@ -14,8 +14,9 @@ class GenericViewsSitemapTests(SitemapTestsBase):
expected
=
''
for
username
in
User
.
objects
.
values_list
(
"username"
,
flat
=
True
):
expected
+=
"<url><loc>
%
s/users/
%
s/</loc></url>"
%
(
self
.
base_url
,
username
)
self
.
assertEqual
(
response
.
content
,
b
"""<?xml version="1.0" encoding="UTF-8"?>
expected_content
=
"""<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
%
s
</urlset>
"""
%
expected
)
"""
%
expected
self
.
assertEqual
(
response
.
content
,
expected_content
.
encode
(
'utf-8'
))
django/contrib/sitemaps/tests/http.py
Dosyayı görüntüle @
37c93187
...
...
@@ -21,11 +21,12 @@ class HTTPSitemapTests(SitemapTestsBase):
def
test_simple_sitemap_index
(
self
):
"A simple sitemap index can be rendered"
response
=
self
.
client
.
get
(
'/simple/index.xml'
)
self
.
assertEqual
(
response
.
content
,
b
"""<?xml version="1.0" encoding="UTF-8"?>
expected_content
=
"""<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>
%
s/simple/sitemap-simple.xml</loc></sitemap>
</sitemapindex>
"""
%
self
.
base_url
)
"""
%
self
.
base_url
self
.
assertEqual
(
response
.
content
,
expected_content
.
encode
(
'utf-8'
))
@override_settings
(
TEMPLATE_DIRS
=
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'templates'
),)
...
...
@@ -33,30 +34,34 @@ class HTTPSitemapTests(SitemapTestsBase):
def
test_simple_sitemap_custom_index
(
self
):
"A simple sitemap index can be rendered with a custom template"
response
=
self
.
client
.
get
(
'/simple/custom-index.xml'
)
self
.
assertEqual
(
response
.
content
,
b
"""<?xml version="1.0" encoding="UTF-8"?>
expected_content
=
"""<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a customised template -->
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>
%
s/simple/sitemap-simple.xml</loc></sitemap>
</sitemapindex>
"""
%
self
.
base_url
)
"""
%
self
.
base_url
self
.
assertEqual
(
response
.
content
,
expected_content
.
encode
(
'utf-8'
))
def
test_simple_sitemap_section
(
self
):
"A simple sitemap section can be rendered"
response
=
self
.
client
.
get
(
'/simple/sitemap-simple.xml'
)
self
.
assertEqual
(
response
.
content
,
b
"""<?xml version="1.0" encoding="UTF-8"?>
expected_content
=
"""<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>
%
s/location/</loc><lastmod>
%
s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
"""
%
(
self
.
base_url
,
date
.
today
()))
"""
%
(
self
.
base_url
,
date
.
today
())
self
.
assertEqual
(
response
.
content
,
expected_content
.
encode
(
'utf-8'
))
def
test_simple_sitemap
(
self
):
"A simple sitemap can be rendered"
response
=
self
.
client
.
get
(
'/simple/sitemap.xml'
)
self
.
assertEqual
(
response
.
content
,
b
"""<?xml version="1.0" encoding="UTF-8"?>
expected_content
=
"""<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>
%
s/location/</loc><lastmod>
%
s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
"""
%
(
self
.
base_url
,
date
.
today
()))
"""
%
(
self
.
base_url
,
date
.
today
())
self
.
assertEqual
(
response
.
content
,
expected_content
.
encode
(
'utf-8'
))
@override_settings
(
TEMPLATE_DIRS
=
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'templates'
),)
...
...
@@ -64,12 +69,13 @@ class HTTPSitemapTests(SitemapTestsBase):
def
test_simple_custom_sitemap
(
self
):
"A simple sitemap can be rendered with a custom template"
response
=
self
.
client
.
get
(
'/simple/custom-sitemap.xml'
)
self
.
assertEqual
(
response
.
content
,
b
"""<?xml version="1.0" encoding="UTF-8"?>
expected_content
=
"""<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a customised template -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>
%
s/location/</loc><lastmod>
%
s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
"""
%
(
self
.
base_url
,
date
.
today
()))
"""
%
(
self
.
base_url
,
date
.
today
())
self
.
assertEqual
(
response
.
content
,
expected_content
.
encode
(
'utf-8'
))
@skipUnless
(
settings
.
USE_I18N
,
"Internationalization is not enabled"
)
@override_settings
(
USE_L10N
=
True
)
...
...
@@ -90,11 +96,12 @@ class HTTPSitemapTests(SitemapTestsBase):
# installed doesn't raise an exception
Site
.
_meta
.
installed
=
False
response
=
self
.
client
.
get
(
'/simple/sitemap.xml'
)
self
.
assertEqual
(
response
.
content
,
b
"""<?xml version="1.0" encoding="UTF-8"?>
expected_content
=
"""<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>http://testserver/location/</loc><lastmod>
%
s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
"""
%
date
.
today
())
"""
%
date
.
today
()
self
.
assertEqual
(
response
.
content
,
expected_content
.
encode
(
'utf-8'
))
@skipUnless
(
"django.contrib.sites"
in
settings
.
INSTALLED_APPS
,
"django.contrib.sites app not installed."
)
...
...
@@ -131,8 +138,9 @@ class HTTPSitemapTests(SitemapTestsBase):
Check that a cached sitemap index can be rendered (#2713).
"""
response
=
self
.
client
.
get
(
'/cached/index.xml'
)
self
.
assertEqual
(
response
.
content
,
b
"""<?xml version="1.0" encoding="UTF-8"?>
expected_content
=
"""<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>
%
s/cached/sitemap-simple.xml</loc></sitemap>
</sitemapindex>
"""
%
self
.
base_url
)
"""
%
self
.
base_url
self
.
assertEqual
(
response
.
content
,
expected_content
.
encode
(
'utf-8'
))
django/contrib/sitemaps/tests/https.py
Dosyayı görüntüle @
37c93187
...
...
@@ -13,20 +13,22 @@ class HTTPSSitemapTests(SitemapTestsBase):
def
test_secure_sitemap_index
(
self
):
"A secure sitemap index can be rendered"
response
=
self
.
client
.
get
(
'/secure/index.xml'
)
self
.
assertEqual
(
response
.
content
,
b
"""<?xml version="1.0" encoding="UTF-8"?>
expected_content
=
"""<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>
%
s/secure/sitemap-simple.xml</loc></sitemap>
</sitemapindex>
"""
%
self
.
base_url
)
"""
%
self
.
base_url
self
.
assertEqual
(
response
.
content
,
expected_content
.
encode
(
'utf-8'
))
def
test_secure_sitemap_section
(
self
):
"A secure sitemap section can be rendered"
response
=
self
.
client
.
get
(
'/secure/sitemap-simple.xml'
)
self
.
assertEqual
(
response
.
content
,
b
"""<?xml version="1.0" encoding="UTF-8"?>
expected_content
=
"""<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>
%
s/location/</loc><lastmod>
%
s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
"""
%
(
self
.
base_url
,
date
.
today
()))
"""
%
(
self
.
base_url
,
date
.
today
())
self
.
assertEqual
(
response
.
content
,
expected_content
.
encode
(
'utf-8'
))
@override_settings
(
SECURE_PROXY_SSL_HEADER
=
False
)
...
...
@@ -36,17 +38,19 @@ class HTTPSDetectionSitemapTests(SitemapTestsBase):
def
test_sitemap_index_with_https_request
(
self
):
"A sitemap index requested in HTTPS is rendered with HTTPS links"
response
=
self
.
client
.
get
(
'/simple/index.xml'
,
**
self
.
extra
)
self
.
assertEqual
(
response
.
content
,
b
"""<?xml version="1.0" encoding="UTF-8"?>
expected_content
=
"""<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>
%
s/simple/sitemap-simple.xml</loc></sitemap>
</sitemapindex>
"""
%
self
.
base_url
.
replace
(
'http://'
,
'https://'
))
"""
%
self
.
base_url
.
replace
(
'http://'
,
'https://'
)
self
.
assertEqual
(
response
.
content
,
expected_content
.
encode
(
'utf-8'
))
def
test_sitemap_section_with_https_request
(
self
):
"A sitemap section requested in HTTPS is rendered with HTTPS links"
response
=
self
.
client
.
get
(
'/simple/sitemap-simple.xml'
,
**
self
.
extra
)
self
.
assertEqual
(
response
.
content
,
b
"""<?xml version="1.0" encoding="UTF-8"?>
expected_content
=
"""<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>
%
s/location/</loc><lastmod>
%
s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
"""
%
(
self
.
base_url
.
replace
(
'http://'
,
'https://'
),
date
.
today
()))
"""
%
(
self
.
base_url
.
replace
(
'http://'
,
'https://'
),
date
.
today
())
self
.
assertEqual
(
response
.
content
,
expected_content
.
encode
(
'utf-8'
))
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