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
b523d425
Kaydet (Commit)
b523d425
authored
Agu 16, 2018
tarafından
Nick Pope
Kaydeden (comit)
Tim Graham
Agu 16, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Reorganized datetime db function tests.
üst
5c3db0ef
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
47 deletions
+49
-47
__init__.py
tests/db_functions/datetime/__init__.py
+0
-0
test_extract_trunc.py
tests/db_functions/datetime/test_extract_trunc.py
+1
-1
test_now.py
tests/db_functions/datetime/test_now.py
+46
-0
tests.py
tests/db_functions/tests.py
+2
-46
No files found.
tests/db_functions/datetime/__init__.py
0 → 100644
Dosyayı görüntüle @
b523d425
tests/db_functions/
test_datetime
.py
→
tests/db_functions/
datetime/test_extract_trunc
.py
Dosyayı görüntüle @
b523d425
...
@@ -17,7 +17,7 @@ from django.test import (
...
@@ -17,7 +17,7 @@ from django.test import (
)
)
from
django.utils
import
timezone
from
django.utils
import
timezone
from
.models
import
Author
,
DTModel
,
Fan
from
.
.
models
import
Author
,
DTModel
,
Fan
def
truncate_to
(
value
,
kind
,
tzinfo
=
None
):
def
truncate_to
(
value
,
kind
,
tzinfo
=
None
):
...
...
tests/db_functions/datetime/test_now.py
0 → 100644
Dosyayı görüntüle @
b523d425
from
datetime
import
datetime
,
timedelta
from
django.db.models.functions
import
Now
from
django.test
import
TestCase
from
django.utils
import
timezone
from
..models
import
Article
lorem_ipsum
=
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua."""
class
NowTests
(
TestCase
):
def
test_basic
(
self
):
a1
=
Article
.
objects
.
create
(
title
=
'How to Django'
,
text
=
lorem_ipsum
,
written
=
timezone
.
now
(),
)
a2
=
Article
.
objects
.
create
(
title
=
'How to Time Travel'
,
text
=
lorem_ipsum
,
written
=
timezone
.
now
(),
)
num_updated
=
Article
.
objects
.
filter
(
id
=
a1
.
id
,
published
=
None
)
.
update
(
published
=
Now
())
self
.
assertEqual
(
num_updated
,
1
)
num_updated
=
Article
.
objects
.
filter
(
id
=
a1
.
id
,
published
=
None
)
.
update
(
published
=
Now
())
self
.
assertEqual
(
num_updated
,
0
)
a1
.
refresh_from_db
()
self
.
assertIsInstance
(
a1
.
published
,
datetime
)
a2
.
published
=
Now
()
+
timedelta
(
days
=
2
)
a2
.
save
()
a2
.
refresh_from_db
()
self
.
assertIsInstance
(
a2
.
published
,
datetime
)
self
.
assertQuerysetEqual
(
Article
.
objects
.
filter
(
published__lte
=
Now
()),
[
'How to Django'
],
lambda
a
:
a
.
title
)
self
.
assertQuerysetEqual
(
Article
.
objects
.
filter
(
published__gt
=
Now
()),
[
'How to Time Travel'
],
lambda
a
:
a
.
title
)
tests/db_functions/tests.py
Dosyayı görüntüle @
b523d425
from
datetime
import
datetime
,
timedelta
from
django.db.models
import
CharField
,
Value
as
V
from
django.db.models
import
CharField
,
Value
as
V
from
django.db.models.functions
import
Coalesce
,
Length
,
Now
,
Upper
from
django.db.models.functions
import
Coalesce
,
Length
,
Upper
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.utils
import
timezone
from
.models
import
Article
,
Author
lorem_ipsum
=
"""
from
.models
import
Author
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua."""
class
FunctionTests
(
TestCase
):
class
FunctionTests
(
TestCase
):
...
@@ -36,43 +29,6 @@ class FunctionTests(TestCase):
...
@@ -36,43 +29,6 @@ class FunctionTests(TestCase):
lambda
a
:
a
.
name
lambda
a
:
a
.
name
)
)
def
test_now
(
self
):
ar1
=
Article
.
objects
.
create
(
title
=
'How to Django'
,
text
=
lorem_ipsum
,
written
=
timezone
.
now
(),
)
ar2
=
Article
.
objects
.
create
(
title
=
'How to Time Travel'
,
text
=
lorem_ipsum
,
written
=
timezone
.
now
(),
)
num_updated
=
Article
.
objects
.
filter
(
id
=
ar1
.
id
,
published
=
None
)
.
update
(
published
=
Now
())
self
.
assertEqual
(
num_updated
,
1
)
num_updated
=
Article
.
objects
.
filter
(
id
=
ar1
.
id
,
published
=
None
)
.
update
(
published
=
Now
())
self
.
assertEqual
(
num_updated
,
0
)
ar1
.
refresh_from_db
()
self
.
assertIsInstance
(
ar1
.
published
,
datetime
)
ar2
.
published
=
Now
()
+
timedelta
(
days
=
2
)
ar2
.
save
()
ar2
.
refresh_from_db
()
self
.
assertIsInstance
(
ar2
.
published
,
datetime
)
self
.
assertQuerysetEqual
(
Article
.
objects
.
filter
(
published__lte
=
Now
()),
[
'How to Django'
],
lambda
a
:
a
.
title
)
self
.
assertQuerysetEqual
(
Article
.
objects
.
filter
(
published__gt
=
Now
()),
[
'How to Time Travel'
],
lambda
a
:
a
.
title
)
def
test_func_transform_bilateral
(
self
):
def
test_func_transform_bilateral
(
self
):
class
UpperBilateral
(
Upper
):
class
UpperBilateral
(
Upper
):
bilateral
=
True
bilateral
=
True
...
...
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