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
36645188
Kaydet (Commit)
36645188
authored
Ock 10, 2018
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Updated HttpRequest.build_absolute_uri() tests to use subTest().
üst
66d74676
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
66 deletions
+26
-66
tests.py
tests/requests/tests.py
+26
-66
No files found.
tests/requests/tests.py
Dosyayı görüntüle @
36645188
...
...
@@ -179,20 +179,6 @@ class RequestsTests(SimpleTestCase):
# left percent-encoded in the path.
self
.
assertEqual
(
request
.
path
,
"/caf
%
E9/"
)
def
test_httprequest_location
(
self
):
request
=
HttpRequest
()
self
.
assertEqual
(
request
.
build_absolute_uri
(
location
=
"https://www.example.com/asdf"
),
'https://www.example.com/asdf'
)
request
.
get_host
=
lambda
:
'www.example.com'
request
.
path
=
''
self
.
assertEqual
(
request
.
build_absolute_uri
(
location
=
"/path/with:colons"
),
'http://www.example.com/path/with:colons'
)
def
test_limited_stream
(
self
):
# Read all of a limited stream
stream
=
LimitedStream
(
BytesIO
(
b
'test'
),
2
)
...
...
@@ -784,62 +770,36 @@ class HostValidationTests(SimpleTestCase):
self
.
assertEqual
(
port
,
'8080'
)
class
BuildAbsoluteURITestCase
(
SimpleTestCase
):
"""
Regression tests for ticket #18314.
"""
def
setUp
(
self
):
self
.
factory
=
RequestFactory
()
def
test_build_absolute_uri_no_location
(
self
):
"""
``request.build_absolute_uri()`` returns the proper value when
the ``location`` argument is not provided, and ``request.path``
begins with //.
"""
# //// is needed to create a request with a path beginning with //
request
=
self
.
factory
.
get
(
'////absolute-uri'
)
self
.
assertEqual
(
request
.
build_absolute_uri
(),
'http://testserver//absolute-uri'
)
class
BuildAbsoluteURITests
(
SimpleTestCase
):
factory
=
RequestFactory
()
def
test_build_absolute_uri_absolute_location
(
self
):
"""
``request.build_absolute_uri()`` returns the proper value when
an absolute URL ``location`` argument is provided, and ``request.path``
begins with //.
"""
# //// is needed to create a request with a path beginning with //
request
=
self
.
factory
.
get
(
'////absolute-uri'
)
self
.
assertEqual
(
request
.
build_absolute_uri
(
location
=
'http://example.com/?foo=bar'
),
'http://example.com/?foo=bar'
)
def
test_absolute_url
(
self
):
request
=
HttpRequest
()
url
=
'https://www.example.com/asdf'
self
.
assertEqual
(
request
.
build_absolute_uri
(
location
=
url
),
url
)
def
test_build_absolute_uri_schema_relative_location
(
self
):
"""
``request.build_absolute_uri()`` returns the proper value when
a schema-relative URL ``location`` argument is provided, and
``request.path`` begins with //.
"""
# //// is needed to create a request with a path beginning with //
request
=
self
.
factory
.
get
(
'////absolute-uri'
)
def
test_host_retrieval
(
self
):
request
=
HttpRequest
()
request
.
get_host
=
lambda
:
'www.example.com'
request
.
path
=
''
self
.
assertEqual
(
request
.
build_absolute_uri
(
location
=
'/
/example.com/?foo=bar
'
),
'http://
example.com/?foo=bar
'
request
.
build_absolute_uri
(
location
=
'/
path/with:colons
'
),
'http://
www.example.com/path/with:colons
'
)
def
test_build_absolute_uri_relative_location
(
self
):
"""
``request.build_absolute_uri()`` returns the proper value when
a relative URL ``location`` argument is provided, and ``request.path``
begins with //.
"""
# //// is needed to create a request with a path beginning with //
def
test_request_path_begins_with_two_slashes
(
self
):
# //// creates a request with a path beginning with //
request
=
self
.
factory
.
get
(
'////absolute-uri'
)
self
.
assertEqual
(
request
.
build_absolute_uri
(
location
=
'/foo/bar/'
),
'http://testserver/foo/bar/'
tests
=
(
# location isn't provided
(
None
,
'http://testserver//absolute-uri'
),
# An absolute URL
(
'http://example.com/?foo=bar'
,
'http://example.com/?foo=bar'
),
# A schema-relative URL
(
'//example.com/?foo=bar'
,
'http://example.com/?foo=bar'
),
# A relative URL
(
'/foo/bar/'
,
'http://testserver/foo/bar/'
),
)
for
location
,
expected_url
in
tests
:
with
self
.
subTest
(
location
=
location
):
self
.
assertEqual
(
request
.
build_absolute_uri
(
location
=
location
),
expected_url
)
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