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
53187830
Kaydet (Commit)
53187830
authored
Haz 25, 2012
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #17966 -- Isolated ProfileTestCase from custom AUTH_PROFILE_MODULE
Thanks Rob Golding for helping on the patch.
üst
d69f1d71
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
23 deletions
+13
-23
models.py
django/contrib/auth/tests/models.py
+13
-23
No files found.
django/contrib/auth/tests/models.py
Dosyayı görüntüle @
53187830
...
...
@@ -5,39 +5,29 @@ from django.contrib.auth.models import (Group, User,
SiteProfileNotAvailable
,
UserManager
)
@override_settings
(
USE_TZ
=
False
)
@override_settings
(
USE_TZ
=
False
,
AUTH_PROFILE_MODULE
=
''
)
class
ProfileTestCase
(
TestCase
):
fixtures
=
[
'authtestdata.json'
]
def
setUp
(
self
):
"""Backs up the AUTH_PROFILE_MODULE"""
self
.
old_AUTH_PROFILE_MODULE
=
getattr
(
settings
,
'AUTH_PROFILE_MODULE'
,
None
)
def
tearDown
(
self
):
"""Restores the AUTH_PROFILE_MODULE -- if it was not set it is deleted,
otherwise the old value is restored"""
if
self
.
old_AUTH_PROFILE_MODULE
is
None
and
\
hasattr
(
settings
,
'AUTH_PROFILE_MODULE'
):
del
settings
.
AUTH_PROFILE_MODULE
if
self
.
old_AUTH_PROFILE_MODULE
is
not
None
:
settings
.
AUTH_PROFILE_MODULE
=
self
.
old_AUTH_PROFILE_MODULE
def
test_site_profile_not_available
(
self
):
user
=
User
.
objects
.
create
(
username
=
'testclient'
)
# calling get_profile without AUTH_PROFILE_MODULE set
if
hasattr
(
settings
,
'AUTH_PROFILE_MODULE'
):
del
settings
.
AUTH_PROFILE_MODULE
user
=
User
.
objects
.
get
(
username
=
'testclient'
)
self
.
assertRaises
(
SiteProfileNotAvailable
,
user
.
get_profile
)
del
settings
.
AUTH_PROFILE_MODULE
with
self
.
assertRaisesRegexp
(
SiteProfileNotAvailable
,
"You need to set AUTH_PROFILE_MODULE in your project"
):
user
.
get_profile
(
)
# Bad syntax in AUTH_PROFILE_MODULE:
settings
.
AUTH_PROFILE_MODULE
=
'foobar'
self
.
assertRaises
(
SiteProfileNotAvailable
,
user
.
get_profile
)
with
self
.
assertRaisesRegexp
(
SiteProfileNotAvailable
,
"app_label and model_name should be separated by a dot"
):
user
.
get_profile
()
# module that doesn't exist
settings
.
AUTH_PROFILE_MODULE
=
'foo.bar'
self
.
assertRaises
(
SiteProfileNotAvailable
,
user
.
get_profile
)
with
self
.
assertRaisesRegexp
(
SiteProfileNotAvailable
,
"Unable to load the profile model"
):
user
.
get_profile
()
@override_settings
(
USE_TZ
=
False
)
...
...
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