summaryrefslogtreecommitdiff
path: root/tests/db_functions
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2021-12-10 09:13:09 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-12-22 11:46:18 +0100
commita8fa3e5cd77416b9e4a5b28b216fb3e19609a37d (patch)
treea6cb44a12f0bbf7bc4796c82f8ae42791363ec36 /tests/db_functions
parent78f062f63e7dea09c219fd1310d43950817f4c78 (diff)
downloaddjango-a8fa3e5cd77416b9e4a5b28b216fb3e19609a37d.tar.gz
Refs #33355 -- Added missing tests for database functions and expression on null values.
Diffstat (limited to 'tests/db_functions')
-rw-r--r--tests/db_functions/math/test_atan2.py2
-rw-r--r--tests/db_functions/math/test_log.py2
-rw-r--r--tests/db_functions/math/test_power.py2
-rw-r--r--tests/db_functions/text/test_pad.py2
-rw-r--r--tests/db_functions/text/test_repeat.py1
5 files changed, 9 insertions, 0 deletions
diff --git a/tests/db_functions/math/test_atan2.py b/tests/db_functions/math/test_atan2.py
index ca12e64479..ce9dd53187 100644
--- a/tests/db_functions/math/test_atan2.py
+++ b/tests/db_functions/math/test_atan2.py
@@ -14,9 +14,11 @@ class ATan2Tests(TestCase):
obj = IntegerModel.objects.annotate(
null_atan2_sn=ATan2('small', 'normal'),
null_atan2_nb=ATan2('normal', 'big'),
+ null_atan2_bn=ATan2('big', 'normal'),
).first()
self.assertIsNone(obj.null_atan2_sn)
self.assertIsNone(obj.null_atan2_nb)
+ self.assertIsNone(obj.null_atan2_bn)
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-9.9'), n2=Decimal('4.6'))
diff --git a/tests/db_functions/math/test_log.py b/tests/db_functions/math/test_log.py
index 469bb7cd3a..293993800a 100644
--- a/tests/db_functions/math/test_log.py
+++ b/tests/db_functions/math/test_log.py
@@ -14,9 +14,11 @@ class LogTests(TestCase):
obj = IntegerModel.objects.annotate(
null_log_small=Log('small', 'normal'),
null_log_normal=Log('normal', 'big'),
+ null_log_big=Log('big', 'normal'),
).first()
self.assertIsNone(obj.null_log_small)
self.assertIsNone(obj.null_log_normal)
+ self.assertIsNone(obj.null_log_big)
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('12.9'), n2=Decimal('3.6'))
diff --git a/tests/db_functions/math/test_power.py b/tests/db_functions/math/test_power.py
index a2d6156e3d..94929d38b7 100644
--- a/tests/db_functions/math/test_power.py
+++ b/tests/db_functions/math/test_power.py
@@ -13,9 +13,11 @@ class PowerTests(TestCase):
obj = IntegerModel.objects.annotate(
null_power_small=Power('small', 'normal'),
null_power_normal=Power('normal', 'big'),
+ null_power_big=Power('big', 'normal'),
).first()
self.assertIsNone(obj.null_power_small)
self.assertIsNone(obj.null_power_normal)
+ self.assertIsNone(obj.null_power_big)
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('1.0'), n2=Decimal('-0.6'))
diff --git a/tests/db_functions/text/test_pad.py b/tests/db_functions/text/test_pad.py
index 17c33a30d8..fbe82c166e 100644
--- a/tests/db_functions/text/test_pad.py
+++ b/tests/db_functions/text/test_pad.py
@@ -25,6 +25,8 @@ class PadTests(TestCase):
(RPad('name', 0), ''),
(LPad('name', None), none_value),
(RPad('name', None), none_value),
+ (LPad(Value(None), 1), none_value),
+ (RPad(Value(None), 1), none_value),
(LPad('goes_by', 1), none_value),
(RPad('goes_by', 1), none_value),
)
diff --git a/tests/db_functions/text/test_repeat.py b/tests/db_functions/text/test_repeat.py
index c1e136c8f0..2234c2e2da 100644
--- a/tests/db_functions/text/test_repeat.py
+++ b/tests/db_functions/text/test_repeat.py
@@ -16,6 +16,7 @@ class RepeatTests(TestCase):
(Repeat('name', Length('alias')), 'JohnJohnJohn'),
(Repeat(Value('x'), 3), 'xxx'),
(Repeat('name', None), none_value),
+ (Repeat(Value(None), 4), none_value),
(Repeat('goes_by', 1), none_value),
)
for function, repeated_text in tests: