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
5e00b144
Kaydet (Commit)
5e00b144
authored
Nis 13, 2016
tarafından
Carl Worth
Kaydeden (comit)
Tim Graham
Nis 21, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added tests for logging of Http404 warnings.
üst
86880ab8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
3 deletions
+51
-3
tests.py
tests/logging_tests/tests.py
+36
-3
urls.py
tests/logging_tests/urls.py
+1
-0
urls_i18n.py
tests/logging_tests/urls_i18n.py
+9
-0
views.py
tests/logging_tests/views.py
+5
-0
No files found.
tests/logging_tests/tests.py
Dosyayı görüntüle @
5e00b144
...
@@ -66,19 +66,22 @@ class LoggingFiltersTest(SimpleTestCase):
...
@@ -66,19 +66,22 @@ class LoggingFiltersTest(SimpleTestCase):
self
.
assertEqual
(
filter_
.
filter
(
"record is not used"
),
False
)
self
.
assertEqual
(
filter_
.
filter
(
"record is not used"
),
False
)
class
DefaultLoggingTest
(
LoggingCaptureMixin
,
SimpleTestCase
):
class
SetupDefaultLoggingMixin
(
object
):
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
super
(
DefaultLoggingTest
,
cls
)
.
setUpClass
()
super
(
SetupDefaultLoggingMixin
,
cls
)
.
setUpClass
()
cls
.
_logging
=
settings
.
LOGGING
cls
.
_logging
=
settings
.
LOGGING
logging
.
config
.
dictConfig
(
DEFAULT_LOGGING
)
logging
.
config
.
dictConfig
(
DEFAULT_LOGGING
)
@classmethod
@classmethod
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
super
(
DefaultLoggingTest
,
cls
)
.
tearDownClass
()
super
(
SetupDefaultLoggingMixin
,
cls
)
.
tearDownClass
()
logging
.
config
.
dictConfig
(
cls
.
_logging
)
logging
.
config
.
dictConfig
(
cls
.
_logging
)
class
DefaultLoggingTests
(
SetupDefaultLoggingMixin
,
LoggingCaptureMixin
,
SimpleTestCase
):
def
test_django_logger
(
self
):
def
test_django_logger
(
self
):
"""
"""
The 'django' base logger only output anything when DEBUG=True.
The 'django' base logger only output anything when DEBUG=True.
...
@@ -106,6 +109,36 @@ class DefaultLoggingTest(LoggingCaptureMixin, SimpleTestCase):
...
@@ -106,6 +109,36 @@ class DefaultLoggingTest(LoggingCaptureMixin, SimpleTestCase):
self
.
assertEqual
(
self
.
logger_output
.
getvalue
(),
''
)
self
.
assertEqual
(
self
.
logger_output
.
getvalue
(),
''
)
@override_settings
(
DEBUG
=
True
,
ROOT_URLCONF
=
'logging_tests.urls'
)
class
HandlerLoggingTests
(
SetupDefaultLoggingMixin
,
LoggingCaptureMixin
,
SimpleTestCase
):
def
test_page_found_no_warning
(
self
):
self
.
client
.
get
(
'/innocent/'
)
self
.
assertEqual
(
self
.
logger_output
.
getvalue
(),
''
)
def
test_page_not_found_warning
(
self
):
self
.
client
.
get
(
'/does_not_exist/'
)
self
.
assertEqual
(
self
.
logger_output
.
getvalue
(),
'Not Found: /does_not_exist/
\n
'
)
@override_settings
(
DEBUG
=
True
,
USE_I18N
=
True
,
LANGUAGES
=
[(
'en'
,
'English'
)],
MIDDLEWARE_CLASSES
=
[
'django.middleware.locale.LocaleMiddleware'
,
'django.middleware.common.CommonMiddleware'
,
],
ROOT_URLCONF
=
'logging_tests.urls_i18n'
,
)
class
I18nLoggingTests
(
SetupDefaultLoggingMixin
,
LoggingCaptureMixin
,
SimpleTestCase
):
def
test_i18n_page_not_found_warning
(
self
):
self
.
client
.
get
(
'/this_does_not/'
)
self
.
client
.
get
(
'/en/nor_this/'
)
self
.
assertEqual
(
self
.
logger_output
.
getvalue
(),
'Not Found: /this_does_not/
\n
Not Found: /en/nor_this/
\n
'
)
class
WarningLoggerTests
(
SimpleTestCase
):
class
WarningLoggerTests
(
SimpleTestCase
):
"""
"""
Tests that warnings output for RemovedInDjangoXXWarning (XX being the next
Tests that warnings output for RemovedInDjangoXXWarning (XX being the next
...
...
tests/logging_tests/urls.py
Dosyayı görüntüle @
5e00b144
...
@@ -5,6 +5,7 @@ from django.conf.urls import url
...
@@ -5,6 +5,7 @@ from django.conf.urls import url
from
.
import
views
from
.
import
views
urlpatterns
=
[
urlpatterns
=
[
url
(
r'^innocent/$'
,
views
.
innocent
),
url
(
r'^suspicious/$'
,
views
.
suspicious
),
url
(
r'^suspicious/$'
,
views
.
suspicious
),
url
(
r'^suspicious_spec/$'
,
views
.
suspicious_spec
),
url
(
r'^suspicious_spec/$'
,
views
.
suspicious_spec
),
]
]
tests/logging_tests/urls_i18n.py
0 → 100644
Dosyayı görüntüle @
5e00b144
from
__future__
import
unicode_literals
from
django.conf.urls
import
url
from
django.conf.urls.i18n
import
i18n_patterns
from
django.http
import
HttpResponse
urlpatterns
=
i18n_patterns
(
url
(
r'^exists/$'
,
lambda
r
:
HttpResponse
()),
)
tests/logging_tests/views.py
Dosyayı görüntüle @
5e00b144
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
django.core.exceptions
import
DisallowedHost
,
SuspiciousOperation
from
django.core.exceptions
import
DisallowedHost
,
SuspiciousOperation
from
django.http
import
HttpResponse
def
innocent
(
request
):
return
HttpResponse
(
'innocent'
)
def
suspicious
(
request
):
def
suspicious
(
request
):
...
...
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