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
22b7870e
Kaydet (Commit)
22b7870e
authored
Mar 13, 2013
tarafından
Florian Apolloner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Began implementing a shared set of test models to speed up tests.
üst
1059da8d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
29 deletions
+19
-29
tests.py
tests/lookup/tests.py
+0
-0
models.py
tests/model_forms/models.py
+5
-22
tests.py
tests/model_forms/tests.py
+0
-0
models.py
tests/shared_models/models.py
+12
-5
tests.py
tests/signals_regress/tests.py
+2
-2
No files found.
tests/lookup/tests.py
Dosyayı görüntüle @
22b7870e
This diff is collapsed.
Click to expand it.
tests/model_forms/models.py
Dosyayı görüntüle @
22b7870e
...
...
@@ -16,6 +16,7 @@ from django.db import models
from
django.utils
import
six
from
django.utils.encoding
import
python_2_unicode_compatible
from
shared_models.models
import
Author
,
Book
temp_storage_dir
=
tempfile
.
mkdtemp
(
dir
=
os
.
environ
[
'DJANGO_TEST_TEMP_DIR'
])
temp_storage
=
FileSystemStorage
(
temp_storage_dir
)
...
...
@@ -44,23 +45,13 @@ class Category(models.Model):
def
__repr__
(
self
):
return
self
.
__str__
()
@python_2_unicode_compatible
class
Writer
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
,
help_text
=
'Use both first and last names.'
)
class
Meta
:
ordering
=
(
'name'
,)
def
__str__
(
self
):
return
self
.
name
@python_2_unicode_compatible
class
Article
(
models
.
Model
):
headline
=
models
.
CharField
(
max_length
=
50
)
slug
=
models
.
SlugField
()
pub_date
=
models
.
DateField
()
created
=
models
.
DateField
(
editable
=
False
)
writer
=
models
.
ForeignKey
(
Write
r
)
writer
=
models
.
ForeignKey
(
Autho
r
)
article
=
models
.
TextField
()
categories
=
models
.
ManyToManyField
(
Category
,
blank
=
True
)
status
=
models
.
PositiveIntegerField
(
choices
=
ARTICLE_STATUS
,
blank
=
True
,
null
=
True
)
...
...
@@ -80,12 +71,12 @@ class ImprovedArticle(models.Model):
class
ImprovedArticleWithParentLink
(
models
.
Model
):
article
=
models
.
OneToOneField
(
Article
,
parent_link
=
True
)
class
Better
Writer
(
Write
r
):
class
Better
Author
(
Autho
r
):
score
=
models
.
IntegerField
()
@python_2_unicode_compatible
class
Write
rProfile
(
models
.
Model
):
writer
=
models
.
OneToOneField
(
Write
r
,
primary_key
=
True
)
class
Autho
rProfile
(
models
.
Model
):
writer
=
models
.
OneToOneField
(
Autho
r
,
primary_key
=
True
)
age
=
models
.
PositiveIntegerField
()
def
__str__
(
self
):
...
...
@@ -192,14 +183,6 @@ class Inventory(models.Model):
def
__repr__
(
self
):
return
self
.
__str__
()
class
Book
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
40
)
author
=
models
.
ForeignKey
(
Writer
,
blank
=
True
,
null
=
True
)
special_id
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
,
unique
=
True
)
class
Meta
:
unique_together
=
(
'title'
,
'author'
)
class
BookXtra
(
models
.
Model
):
isbn
=
models
.
CharField
(
max_length
=
16
,
unique
=
True
)
suffix1
=
models
.
IntegerField
(
blank
=
True
,
default
=
0
)
...
...
tests/model_forms/tests.py
Dosyayı görüntüle @
22b7870e
This diff is collapsed.
Click to expand it.
tests/shared_models/models.py
Dosyayı görüntüle @
22b7870e
from
__future__
import
unicode_literals
from
django.db
import
models
from
django.utils
import
timezone
from
django.utils.encoding
import
python_2_unicode_compatible
...
...
@@ -9,7 +11,11 @@ class Tag(models.Model):
@python_2_unicode_compatible
class
Author
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
)
name
=
models
.
CharField
(
max_length
=
100
,
help_text
=
'Use both first and last names.'
,
unique
=
True
)
class
Meta
:
ordering
=
[
'name'
]
def
__str__
(
self
):
return
self
.
name
...
...
@@ -17,14 +23,15 @@ class Author(models.Model):
@python_2_unicode_compatible
class
Book
(
models
.
Model
):
nam
e
=
models
.
CharField
(
max_length
=
200
)
titl
e
=
models
.
CharField
(
max_length
=
200
)
pages
=
models
.
IntegerField
(
default
=
0
)
author
=
models
.
ForeignKey
(
Author
,
null
=
True
)
author
=
models
.
ForeignKey
(
Author
,
null
=
True
,
blank
=
True
)
pubdate
=
models
.
DateTimeField
()
tags
=
models
.
ManyToManyField
(
Tag
)
class
Meta
:
ordering
=
[
'-pubdate'
,
'name'
]
ordering
=
[
'-pubdate'
,
'title'
]
unique_together
=
[
'title'
,
'author'
]
def
__str__
(
self
):
return
self
.
nam
e
return
self
.
titl
e
tests/signals_regress/tests.py
Dosyayı görüntüle @
22b7870e
...
...
@@ -77,7 +77,7 @@ class SignalsRegressTests(TestCase):
"Is created"
])
b1
=
Book
(
nam
e
=
'Snow Crash'
,
pubdate
=
'2012-02-02 12:00'
)
b1
=
Book
(
titl
e
=
'Snow Crash'
,
pubdate
=
'2012-02-02 12:00'
)
self
.
assertEqual
(
self
.
get_signal_output
(
b1
.
save
),
[
"pre_save signal, Snow Crash"
,
"post_save signal, Snow Crash"
,
...
...
@@ -87,7 +87,7 @@ class SignalsRegressTests(TestCase):
def
test_m2m_signals
(
self
):
""" Assigning and removing to/from m2m shouldn't generate an m2m signal """
b1
=
Book
(
nam
e
=
'Snow Crash'
,
pubdate
=
'2012-02-02 12:00'
)
b1
=
Book
(
titl
e
=
'Snow Crash'
,
pubdate
=
'2012-02-02 12:00'
)
self
.
get_signal_output
(
b1
.
save
)
a1
=
Author
(
name
=
'Neal Stephenson'
)
self
.
get_signal_output
(
a1
.
save
)
...
...
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