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
57f4b3ce
Kaydet (Commit)
57f4b3ce
authored
Haz 19, 2017
tarafından
Anton Samarchyan
Kaydeden (comit)
Tim Graham
Haz 19, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added tests for AdminSite's add/disable/get action methods.
üst
90294cc2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletion
+27
-1
test_adminsite.py
tests/admin_views/test_adminsite.py
+27
-1
No files found.
tests/admin_views/test_adminsite.py
Dosyayı görüntüle @
57f4b3ce
from
django.conf.urls
import
url
from
django.contrib
import
admin
from
django.contrib.admin.actions
import
delete_selected
from
django.contrib.auth.models
import
User
from
django.test
import
TestCase
,
override_settings
from
django.test
import
SimpleTestCase
,
TestCase
,
override_settings
from
django.test.client
import
RequestFactory
from
django.urls
import
reverse
...
...
@@ -73,3 +74,28 @@ class SiteEachContextTest(TestCase):
self
.
assertEqual
(
user
[
'admin_url'
],
'/test_admin/admin/auth/user/'
)
self
.
assertEqual
(
user
[
'add_url'
],
'/test_admin/admin/auth/user/add/'
)
self
.
assertEqual
(
user
[
'name'
],
'Users'
)
class
SiteActionsTests
(
SimpleTestCase
):
def
setUp
(
self
):
self
.
site
=
admin
.
AdminSite
()
def
test_add_action
(
self
):
def
test_action
():
pass
self
.
site
.
add_action
(
test_action
)
self
.
assertEqual
(
self
.
site
.
get_action
(
'test_action'
),
test_action
)
def
test_disable_action
(
self
):
action_name
=
'delete_selected'
self
.
assertEqual
(
self
.
site
.
_actions
[
action_name
],
delete_selected
)
self
.
site
.
disable_action
(
action_name
)
with
self
.
assertRaises
(
KeyError
):
self
.
site
.
_actions
[
action_name
]
def
test_get_action
(
self
):
"""AdminSite.get_action() returns an action even if it's disabled."""
action_name
=
'delete_selected'
self
.
assertEqual
(
self
.
site
.
get_action
(
action_name
),
delete_selected
)
self
.
site
.
disable_action
(
action_name
)
self
.
assertEqual
(
self
.
site
.
get_action
(
action_name
),
delete_selected
)
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