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
d02e3314
Kaydet (Commit)
d02e3314
authored
May 21, 2016
tarafından
Simon Charette
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Avoided uncessary table creation in model_inheritance tests.
üst
53a5fb3c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
69 deletions
+30
-69
models.py
tests/model_inheritance/models.py
+0
-8
__init__.py
tests/model_inheritance/same_model_name/__init__.py
+0
-0
models.py
tests/model_inheritance/same_model_name/models.py
+0
-19
tests.py
tests/model_inheritance/tests.py
+30
-42
No files found.
tests/model_inheritance/models.py
Dosyayı görüntüle @
d02e3314
...
@@ -168,14 +168,6 @@ class NamedURL(models.Model):
...
@@ -168,14 +168,6 @@ class NamedURL(models.Model):
abstract
=
True
abstract
=
True
@python_2_unicode_compatible
class
Copy
(
NamedURL
):
content
=
models
.
TextField
()
def
__str__
(
self
):
return
self
.
content
class
Mixin
(
object
):
class
Mixin
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
other_attr
=
1
self
.
other_attr
=
1
...
...
tests/model_inheritance/same_model_name/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
53a5fb3c
tests/model_inheritance/same_model_name/models.py
deleted
100644 → 0
Dosyayı görüntüle @
53a5fb3c
"""
Model inheritance across apps can result in models with the same name,
requiring an
%(app_label)
s format string. This app tests this feature by
redefining the Copy model from model_inheritance/models.py.
"""
from
model_inheritance.models
import
NamedURL
from
django.db
import
models
from
django.utils.encoding
import
python_2_unicode_compatible
@python_2_unicode_compatible
class
Copy
(
NamedURL
):
content
=
models
.
TextField
()
def
__str__
(
self
):
return
self
.
content
tests/model_inheritance/tests.py
Dosyayı görüntüle @
d02e3314
...
@@ -3,14 +3,13 @@ from __future__ import unicode_literals
...
@@ -3,14 +3,13 @@ from __future__ import unicode_literals
from
operator
import
attrgetter
from
operator
import
attrgetter
from
django.core.exceptions
import
FieldError
,
ValidationError
from
django.core.exceptions
import
FieldError
,
ValidationError
from
django.core.management
import
call_command
from
django.db
import
connection
,
models
from
django.db
import
connection
,
models
from
django.test
import
TestCase
,
Transaction
TestCase
from
django.test
import
SimpleTestCase
,
TestCase
from
django.test.utils
import
CaptureQueriesContext
,
isolate_apps
from
django.test.utils
import
CaptureQueriesContext
,
isolate_apps
from
django.utils
import
six
from
django.utils
import
six
from
.models
import
(
from
.models
import
(
Base
,
Chef
,
CommonInfo
,
Copy
,
GrandChild
,
GrandParent
,
ItalianRestaurant
,
Base
,
Chef
,
CommonInfo
,
GrandChild
,
GrandParent
,
ItalianRestaurant
,
MixinModel
,
ParkingLot
,
Place
,
Post
,
Restaurant
,
Student
,
SubBase
,
MixinModel
,
ParkingLot
,
Place
,
Post
,
Restaurant
,
Student
,
SubBase
,
Supplier
,
Title
,
Worker
,
Supplier
,
Title
,
Worker
,
)
)
...
@@ -399,48 +398,37 @@ class ModelInheritanceDataTests(TestCase):
...
@@ -399,48 +398,37 @@ class ModelInheritanceDataTests(TestCase):
)
)
class
InheritanceSameModelNameTests
(
TransactionTestCase
):
@isolate_apps
(
'model_inheritance'
,
'model_inheritance.tests'
)
class
InheritanceSameModelNameTests
(
SimpleTestCase
):
def
test_abstract_fk_related_name
(
self
):
related_name
=
'
%(app_label)
s_
%(class)
s_references'
available_apps
=
[
'model_inheritance'
]
class
Referenced
(
models
.
Model
):
class
Meta
:
app_label
=
'model_inheritance'
def
setUp
(
self
):
class
AbstractReferent
(
models
.
Model
):
# The Title model has distinct accessors for both
reference
=
models
.
ForeignKey
(
Referenced
,
models
.
CASCADE
,
related_name
=
related_name
)
# model_inheritance.Copy and model_inheritance_same_model_name.Copy
# models.
self
.
title
=
Title
.
objects
.
create
(
title
=
'Lorem Ipsum'
)
def
test_inheritance_related_name
(
self
):
class
Meta
:
self
.
assertEqual
(
app_label
=
'model_inheritance'
self
.
title
.
attached_model_inheritance_copy_set
.
create
(
abstract
=
True
content
=
'Save $ on V1agr@'
,
url
=
'http://v1agra.com/'
,
class
Referent
(
AbstractReferent
):
title
=
'V1agra is spam'
,
class
Meta
:
),
Copy
.
objects
.
get
(
app_label
=
'model_inheritance'
content
=
'Save $ on V1agr@'
,
))
LocalReferent
=
Referent
def
test_inheritance_with_same_model_name
(
self
):
class
Referent
(
AbstractReferent
):
with
self
.
modify_settings
(
class
Meta
:
INSTALLED_APPS
=
{
'append'
:
[
'model_inheritance.same_model_name'
]}):
app_label
=
'tests'
call_command
(
'migrate'
,
verbosity
=
0
,
run_syncdb
=
True
)
from
.same_model_name.models
import
Copy
ForeignReferent
=
Referent
copy
=
self
.
title
.
attached_same_model_name_copy_set
.
create
(
content
=
'The Web framework for perfectionists with deadlines.'
,
self
.
assertFalse
(
hasattr
(
Referenced
,
related_name
))
url
=
'http://www.djangoproject.com/'
,
self
.
assertTrue
(
Referenced
.
model_inheritance_referent_references
.
rel
.
model
,
LocalReferent
)
title
=
'Django Rocks'
self
.
assertTrue
(
Referenced
.
tests_referent_references
.
rel
.
model
,
ForeignReferent
)
)
self
.
assertEqual
(
copy
,
Copy
.
objects
.
get
(
content
=
'The Web framework for perfectionists with deadlines.'
,
))
# We delete the copy manually so that it doesn't block the flush
# command under Oracle (which does not cascade deletions).
copy
.
delete
()
def
test_related_name_attribute_exists
(
self
):
# The Post model doesn't have an attribute called 'attached_%(app_label)s_%(class)s_set'.
self
.
assertFalse
(
hasattr
(
self
.
title
,
'attached_
%(app_label)
s_
%(class)
s_set'
))
class
InheritanceUniqueTests
(
TestCase
):
class
InheritanceUniqueTests
(
TestCase
):
...
...
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