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
7fce4dc5
Kaydet (Commit)
7fce4dc5
authored
Eyl 28, 2017
tarafından
Mads Jensen
Kaydeden (comit)
Tim Graham
Eyl 28, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Moved AnonymousUser tests to its own test case.
üst
2b5a511b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
16 deletions
+20
-16
test_basic.py
tests/auth_tests/test_basic.py
+0
-14
test_models.py
tests/auth_tests/test_models.py
+20
-2
No files found.
tests/auth_tests/test_basic.py
Dosyayı görüntüle @
7fce4dc5
...
...
@@ -62,20 +62,6 @@ class BasicTestCase(TestCase):
u3
=
User
.
objects
.
create_user
(
'testuser3'
,
email
=
None
)
self
.
assertEqual
(
u3
.
email
,
''
)
def
test_anonymous_user
(
self
):
"Check the properties of the anonymous user"
a
=
AnonymousUser
()
self
.
assertIsNone
(
a
.
pk
)
self
.
assertEqual
(
a
.
username
,
''
)
self
.
assertEqual
(
a
.
get_username
(),
''
)
self
.
assertTrue
(
a
.
is_anonymous
)
self
.
assertFalse
(
a
.
is_authenticated
)
self
.
assertFalse
(
a
.
is_staff
)
self
.
assertFalse
(
a
.
is_active
)
self
.
assertFalse
(
a
.
is_superuser
)
self
.
assertEqual
(
a
.
groups
.
all
()
.
count
(),
0
)
self
.
assertEqual
(
a
.
user_permissions
.
all
()
.
count
(),
0
)
def
test_superuser
(
self
):
"Check the creation and properties of a superuser"
super
=
User
.
objects
.
create_superuser
(
'super'
,
'super@example.com'
,
'super'
)
...
...
tests/auth_tests/test_models.py
Dosyayı görüntüle @
7fce4dc5
...
...
@@ -5,12 +5,12 @@ from django.contrib.auth import get_user_model
from
django.contrib.auth.base_user
import
AbstractBaseUser
from
django.contrib.auth.hashers
import
get_hasher
from
django.contrib.auth.models
import
(
AbstractUser
,
Group
,
Permission
,
User
,
UserManager
,
AbstractUser
,
AnonymousUser
,
Group
,
Permission
,
User
,
UserManager
,
)
from
django.contrib.contenttypes.models
import
ContentType
from
django.core
import
mail
from
django.db.models.signals
import
post_save
from
django.test
import
TestCase
,
override_settings
from
django.test
import
SimpleTestCase
,
TestCase
,
override_settings
from
.models.with_custom_email_field
import
CustomEmailField
...
...
@@ -303,3 +303,21 @@ class TestCreateSuperUserSignals(TestCase):
def
test_create_superuser
(
self
):
User
.
objects
.
create_superuser
(
"JohnDoe"
,
"mail@example.com"
,
"1"
)
self
.
assertEqual
(
self
.
signals_count
,
1
)
class
AnonymousUserTests
(
SimpleTestCase
):
def
setUp
(
self
):
self
.
user
=
AnonymousUser
()
def
test_properties
(
self
):
self
.
assertIsNone
(
self
.
user
.
pk
)
self
.
assertEqual
(
self
.
user
.
username
,
''
)
self
.
assertEqual
(
self
.
user
.
get_username
(),
''
)
self
.
assertIs
(
self
.
user
.
is_anonymous
,
True
)
self
.
assertIs
(
self
.
user
.
is_authenticated
,
False
)
self
.
assertIs
(
self
.
user
.
is_staff
,
False
)
self
.
assertIs
(
self
.
user
.
is_active
,
False
)
self
.
assertIs
(
self
.
user
.
is_superuser
,
False
)
self
.
assertEqual
(
self
.
user
.
groups
.
all
()
.
count
(),
0
)
self
.
assertEqual
(
self
.
user
.
user_permissions
.
all
()
.
count
(),
0
)
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