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
b3ee80a0
Kaydet (Commit)
b3ee80a0
authored
Eyl 26, 2012
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed parse_http_date docstring and moved related tests
Refs #18675.
üst
bb7da784
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
32 deletions
+31
-32
http.py
django/utils/http.py
+1
-2
models.py
tests/regressiontests/conditional_processing/models.py
+0
-29
http.py
tests/regressiontests/utils/http.py
+29
-0
tests.py
tests/regressiontests/utils/tests.py
+1
-1
No files found.
django/utils/http.py
Dosyayı görüntüle @
b3ee80a0
...
...
@@ -118,8 +118,7 @@ def parse_http_date(date):
The three formats allowed by the RFC are accepted, even if only the first
one is still in widespread use.
Returns an floating point number expressed in seconds since the epoch, in
UTC.
Returns an integer expressed in seconds since the epoch, in UTC.
"""
# emails.Util.parsedate does the job for RFC1123 dates; unfortunately
# RFC2616 makes it mandatory to support RFC850 dates too. So we roll
...
...
tests/regressiontests/conditional_processing/models.py
Dosyayı görüntüle @
b3ee80a0
...
...
@@ -4,8 +4,6 @@ from __future__ import unicode_literals
from
datetime
import
datetime
from
django.test
import
TestCase
from
django.utils
import
unittest
from
django.utils.http
import
parse_etags
,
quote_etag
,
parse_http_date
FULL_RESPONSE
=
'Test conditional get response'
...
...
@@ -129,30 +127,3 @@ class ConditionalGet(TestCase):
self
.
client
.
defaults
[
'HTTP_IF_NONE_MATCH'
]
=
r'"\"'
response
=
self
.
client
.
get
(
'/condition/etag/'
)
self
.
assertFullResponse
(
response
,
check_last_modified
=
False
)
class
ETagProcessing
(
unittest
.
TestCase
):
def
testParsing
(
self
):
etags
=
parse_etags
(
r'"", "etag", "e\"t\"ag", "e\\tag", W/"weak"'
)
self
.
assertEqual
(
etags
,
[
''
,
'etag'
,
'e"t"ag'
,
r'e\tag'
,
'weak'
])
def
testQuoting
(
self
):
quoted_etag
=
quote_etag
(
r'e\t"ag'
)
self
.
assertEqual
(
quoted_etag
,
r'"e\\t\"ag"'
)
class
HttpDateProcessing
(
unittest
.
TestCase
):
def
testParsingRfc1123
(
self
):
parsed
=
parse_http_date
(
'Sun, 06 Nov 1994 08:49:37 GMT'
)
self
.
assertEqual
(
datetime
.
utcfromtimestamp
(
parsed
),
datetime
(
1994
,
11
,
6
,
8
,
49
,
37
))
def
testParsingRfc850
(
self
):
parsed
=
parse_http_date
(
'Sunday, 06-Nov-94 08:49:37 GMT'
)
self
.
assertEqual
(
datetime
.
utcfromtimestamp
(
parsed
),
datetime
(
1994
,
11
,
6
,
8
,
49
,
37
))
def
testParsingAsctime
(
self
):
parsed
=
parse_http_date
(
'Sun Nov 6 08:49:37 1994'
)
self
.
assertEqual
(
datetime
.
utcfromtimestamp
(
parsed
),
datetime
(
1994
,
11
,
6
,
8
,
49
,
37
))
tests/regressiontests/utils/http.py
Dosyayı görüntüle @
b3ee80a0
from
datetime
import
datetime
import
sys
from
django.http
import
HttpResponse
,
utils
...
...
@@ -7,6 +8,7 @@ from django.utils import http
from
django.utils
import
six
from
django.utils
import
unittest
class
TestUtilsHttp
(
unittest
.
TestCase
):
def
test_same_origin_true
(
self
):
...
...
@@ -132,3 +134,30 @@ class TestUtilsHttp(unittest.TestCase):
for
n
,
b36
in
[(
0
,
'0'
),
(
1
,
'1'
),
(
42
,
'16'
),
(
818469960
,
'django'
)]:
self
.
assertEqual
(
http
.
int_to_base36
(
n
),
b36
)
self
.
assertEqual
(
http
.
base36_to_int
(
b36
),
n
)
class
ETagProcessingTests
(
unittest
.
TestCase
):
def
testParsing
(
self
):
etags
=
http
.
parse_etags
(
r'"", "etag", "e\"t\"ag", "e\\tag", W/"weak"'
)
self
.
assertEqual
(
etags
,
[
''
,
'etag'
,
'e"t"ag'
,
r'e\tag'
,
'weak'
])
def
testQuoting
(
self
):
quoted_etag
=
http
.
quote_etag
(
r'e\t"ag'
)
self
.
assertEqual
(
quoted_etag
,
r'"e\\t\"ag"'
)
class
HttpDateProcessingTests
(
unittest
.
TestCase
):
def
testParsingRfc1123
(
self
):
parsed
=
http
.
parse_http_date
(
'Sun, 06 Nov 1994 08:49:37 GMT'
)
self
.
assertEqual
(
datetime
.
utcfromtimestamp
(
parsed
),
datetime
(
1994
,
11
,
6
,
8
,
49
,
37
))
def
testParsingRfc850
(
self
):
parsed
=
http
.
parse_http_date
(
'Sunday, 06-Nov-94 08:49:37 GMT'
)
self
.
assertEqual
(
datetime
.
utcfromtimestamp
(
parsed
),
datetime
(
1994
,
11
,
6
,
8
,
49
,
37
))
def
testParsingAsctime
(
self
):
parsed
=
http
.
parse_http_date
(
'Sun Nov 6 08:49:37 1994'
)
self
.
assertEqual
(
datetime
.
utcfromtimestamp
(
parsed
),
datetime
(
1994
,
11
,
6
,
8
,
49
,
37
))
tests/regressiontests/utils/tests.py
Dosyayı görüntüle @
b3ee80a0
...
...
@@ -17,7 +17,7 @@ from .encoding import TestEncodingUtils
from
.feedgenerator
import
FeedgeneratorTest
from
.functional
import
FunctionalTestCase
from
.html
import
TestUtilsHtml
from
.http
import
TestUtilsHttp
from
.http
import
TestUtilsHttp
,
ETagProcessingTests
,
HttpDateProcessingTests
from
.ipv6
import
TestUtilsIPv6
from
.jslex
import
JsToCForGettextTest
,
JsTokensTest
from
.module_loading
import
CustomLoader
,
DefaultLoader
,
EggLoader
...
...
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