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
04e69598
Kaydet (Commit)
04e69598
authored
Tem 16, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #24919 -- Made test models serializable for migrations.
üst
8a5eadd1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
38 deletions
+72
-38
models.py
tests/admin_views/models.py
+5
-3
models.py
tests/delete/models.py
+2
-1
fields.py
tests/field_subclassing/fields.py
+2
-0
models.py
tests/forms_tests/models.py
+54
-14
models.py
tests/queryset_pickle/models.py
+5
-13
tests.py
tests/queryset_pickle/tests.py
+4
-7
No files found.
tests/admin_views/models.py
Dosyayı görüntüle @
04e69598
...
...
@@ -422,10 +422,12 @@ class Category(models.Model):
return
'
%
s:o
%
s'
%
(
self
.
id
,
self
.
order
)
def
link_posted_default
():
return
datetime
.
date
.
today
()
-
datetime
.
timedelta
(
days
=
7
)
class
Link
(
models
.
Model
):
posted
=
models
.
DateField
(
default
=
lambda
:
datetime
.
date
.
today
()
-
datetime
.
timedelta
(
days
=
7
)
)
posted
=
models
.
DateField
(
default
=
link_posted_default
)
url
=
models
.
URLField
()
post
=
models
.
ForeignKey
(
"Post"
)
...
...
tests/delete/models.py
Dosyayı görüntüle @
04e69598
...
...
@@ -12,7 +12,8 @@ class R(models.Model):
return
"
%
s"
%
self
.
pk
get_default_r
=
lambda
:
R
.
objects
.
get_or_create
(
is_default
=
True
)[
0
]
def
get_default_r
():
return
R
.
objects
.
get_or_create
(
is_default
=
True
)[
0
]
class
S
(
models
.
Model
):
...
...
tests/field_subclassing/fields.py
Dosyayı görüntüle @
04e69598
...
...
@@ -5,6 +5,7 @@ import warnings
from
django.db
import
models
from
django.utils
import
six
from
django.utils.deconstruct
import
deconstructible
from
django.utils.deprecation
import
RemovedInDjango110Warning
from
django.utils.encoding
import
force_text
,
python_2_unicode_compatible
...
...
@@ -16,6 +17,7 @@ warnings.filterwarnings(
)
@deconstructible
@python_2_unicode_compatible
class
Small
(
object
):
"""
...
...
tests/forms_tests/models.py
Dosyayı görüntüle @
04e69598
...
...
@@ -10,7 +10,10 @@ from django.db import models
from
django.utils.encoding
import
python_2_unicode_compatible
callable_default_counter
=
itertools
.
count
()
callable_default
=
lambda
:
next
(
callable_default_counter
)
def
callable_default
():
return
next
(
callable_default_counter
)
temp_storage
=
FileSystemStorage
(
location
=
tempfile
.
mkdtemp
())
...
...
@@ -68,25 +71,62 @@ class ChoiceOptionModel(models.Model):
return
'ChoiceOption
%
d'
%
self
.
pk
def
choice_default
():
return
ChoiceOptionModel
.
objects
.
get_or_create
(
name
=
'default'
)[
0
]
def
choice_default_list
():
return
[
choice_default
()]
def
int_default
():
return
1
def
int_list_default
():
return
[
1
]
class
ChoiceFieldModel
(
models
.
Model
):
"""Model with ForeignKey to another model, for testing ModelForm
generation with ModelChoiceField."""
choice
=
models
.
ForeignKey
(
ChoiceOptionModel
,
blank
=
False
,
default
=
lambda
:
ChoiceOptionModel
.
objects
.
get
(
name
=
'default'
))
choice_int
=
models
.
ForeignKey
(
ChoiceOptionModel
,
blank
=
False
,
related_name
=
'choice_int'
,
default
=
lambda
:
1
)
multi_choice
=
models
.
ManyToManyField
(
ChoiceOptionModel
,
blank
=
False
,
related_name
=
'multi_choice'
,
default
=
lambda
:
ChoiceOptionModel
.
objects
.
filter
(
name
=
'default'
))
multi_choice_int
=
models
.
ManyToManyField
(
ChoiceOptionModel
,
blank
=
False
,
related_name
=
'multi_choice_int'
,
default
=
lambda
:
[
1
])
choice
=
models
.
ForeignKey
(
ChoiceOptionModel
,
blank
=
False
,
default
=
choice_default
,
)
choice_int
=
models
.
ForeignKey
(
ChoiceOptionModel
,
blank
=
False
,
related_name
=
'choice_int'
,
default
=
int_default
,
)
multi_choice
=
models
.
ManyToManyField
(
ChoiceOptionModel
,
blank
=
False
,
related_name
=
'multi_choice'
,
default
=
choice_default_list
,
)
multi_choice_int
=
models
.
ManyToManyField
(
ChoiceOptionModel
,
blank
=
False
,
related_name
=
'multi_choice_int'
,
default
=
int_list_default
,
)
class
OptionalMultiChoiceModel
(
models
.
Model
):
multi_choice
=
models
.
ManyToManyField
(
ChoiceOptionModel
,
blank
=
False
,
related_name
=
'not_relevant'
,
default
=
lambda
:
ChoiceOptionModel
.
objects
.
filter
(
name
=
'default'
))
multi_choice_optional
=
models
.
ManyToManyField
(
ChoiceOptionModel
,
blank
=
True
,
related_name
=
'not_relevant2'
)
multi_choice
=
models
.
ManyToManyField
(
ChoiceOptionModel
,
blank
=
False
,
related_name
=
'not_relevant'
,
default
=
choice_default
,
)
multi_choice_optional
=
models
.
ManyToManyField
(
ChoiceOptionModel
,
blank
=
True
,
related_name
=
'not_relevant2'
,
)
class
FileModel
(
models
.
Model
):
...
...
tests/queryset_pickle/models.py
Dosyayı görüntüle @
04e69598
import
datetime
from
django.db
import
DJANGO_VERSION_PICKLE_KEY
,
models
from
django.utils
import
six
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
@@ -13,15 +14,6 @@ class Numbers(object):
def
get_static_number
():
return
2
@classmethod
def
get_class_number
(
cls
):
return
3
def
get_member_number
(
self
):
return
4
nn
=
Numbers
()
class
PreviousDjangoVersionQuerySet
(
models
.
QuerySet
):
def
__getstate__
(
self
):
...
...
@@ -51,11 +43,11 @@ class Event(models.Model):
class
Happening
(
models
.
Model
):
when
=
models
.
DateTimeField
(
blank
=
True
,
default
=
datetime
.
datetime
.
now
)
name
=
models
.
CharField
(
blank
=
True
,
max_length
=
100
,
default
=
lambda
:
"test"
)
name
=
models
.
CharField
(
blank
=
True
,
max_length
=
100
,
default
=
"test"
)
number1
=
models
.
IntegerField
(
blank
=
True
,
default
=
standalone_number
)
number2
=
models
.
IntegerField
(
blank
=
True
,
default
=
Numbers
.
get_static_number
)
number3
=
models
.
IntegerField
(
blank
=
True
,
default
=
Numbers
.
get_class_number
)
number4
=
models
.
IntegerField
(
blank
=
True
,
default
=
nn
.
get_member
_number
)
if
six
.
PY3
:
# default serializable on Python 3 only
number2
=
models
.
IntegerField
(
blank
=
True
,
default
=
Numbers
.
get_static
_number
)
class
Container
(
object
):
...
...
tests/queryset_pickle/tests.py
Dosyayı görüntüle @
04e69598
...
...
@@ -2,9 +2,11 @@ from __future__ import unicode_literals
import
datetime
import
pickle
import
unittest
import
warnings
from
django.test
import
TestCase
from
django.utils
import
six
from
django.utils.encoding
import
force_text
from
django.utils.version
import
get_version
...
...
@@ -28,21 +30,16 @@ class PickleabilityTestCase(TestCase):
def
test_datetime_callable_default_filter
(
self
):
self
.
assert_pickles
(
Happening
.
objects
.
filter
(
when
=
datetime
.
datetime
.
now
()))
def
test_
lambda
_as_default
(
self
):
def
test_
string
_as_default
(
self
):
self
.
assert_pickles
(
Happening
.
objects
.
filter
(
name
=
"test"
))
def
test_standalone_method_as_default
(
self
):
self
.
assert_pickles
(
Happening
.
objects
.
filter
(
number1
=
1
))
@unittest.skipIf
(
six
.
PY2
,
"Field doesn't exist on Python 2."
)
def
test_staticmethod_as_default
(
self
):
self
.
assert_pickles
(
Happening
.
objects
.
filter
(
number2
=
1
))
def
test_classmethod_as_default
(
self
):
self
.
assert_pickles
(
Happening
.
objects
.
filter
(
number3
=
1
))
def
test_membermethod_as_default
(
self
):
self
.
assert_pickles
(
Happening
.
objects
.
filter
(
number4
=
1
))
def
test_filter_reverse_fk
(
self
):
self
.
assert_pickles
(
Group
.
objects
.
filter
(
event
=
1
))
...
...
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