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
f88e7608
Kaydet (Commit)
f88e7608
authored
Kas 24, 2013
tarafından
Antonis Christofides
Kaydeden (comit)
Baptiste Mispelon
Kas 24, 2013
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added more tests for ContentTypeManager.get_for_model.
üst
e681b286
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
tests.py
tests/contenttypes_tests/tests.py
+21
-0
No files found.
tests/contenttypes_tests/tests.py
Dosyayı görüntüle @
f88e7608
from
__future__
import
unicode_literals
from
django.contrib.contenttypes.models
import
ContentType
from
django.db
import
models
from
django.db.models.loading
import
BaseAppCache
from
django.test
import
TestCase
from
.models
import
Author
,
Article
...
...
@@ -46,3 +48,22 @@ class ContentTypesViewsTests(TestCase):
short_url
=
'/shortcut/
%
s/
%
s/'
%
(
42424242
,
an_author
.
pk
)
response
=
self
.
client
.
get
(
short_url
)
self
.
assertEqual
(
response
.
status_code
,
404
)
def
test_create_contenttype_on_the_spot
(
self
):
"""
Make sure ContentTypeManager.get_for_model creates the corresponding
content type if it doesn't exist in the database (for some reason).
"""
class
ModelCreatedOnTheFly
(
models
.
Model
):
name
=
models
.
CharField
()
class
Meta
:
verbose_name
=
'a model created on the fly'
app_label
=
'my_great_app'
app_cache
=
BaseAppCache
()
ct
=
ContentType
.
objects
.
get_for_model
(
ModelCreatedOnTheFly
)
self
.
assertEqual
(
ct
.
app_label
,
'my_great_app'
)
self
.
assertEqual
(
ct
.
model
,
'modelcreatedonthefly'
)
self
.
assertEqual
(
ct
.
name
,
'a model created on the fly'
)
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