summaryrefslogtreecommitdiff
path: root/tests/db_functions/math
diff options
context:
space:
mode:
Diffstat (limited to 'tests/db_functions/math')
-rw-r--r--tests/db_functions/math/test_abs.py5
-rw-r--r--tests/db_functions/math/test_acos.py5
-rw-r--r--tests/db_functions/math/test_asin.py5
-rw-r--r--tests/db_functions/math/test_atan.py5
-rw-r--r--tests/db_functions/math/test_atan2.py9
-rw-r--r--tests/db_functions/math/test_ceil.py5
-rw-r--r--tests/db_functions/math/test_cos.py5
-rw-r--r--tests/db_functions/math/test_cot.py5
-rw-r--r--tests/db_functions/math/test_degrees.py5
-rw-r--r--tests/db_functions/math/test_exp.py5
-rw-r--r--tests/db_functions/math/test_floor.py5
-rw-r--r--tests/db_functions/math/test_ln.py5
-rw-r--r--tests/db_functions/math/test_log.py9
-rw-r--r--tests/db_functions/math/test_mod.py9
-rw-r--r--tests/db_functions/math/test_power.py9
-rw-r--r--tests/db_functions/math/test_radians.py5
-rw-r--r--tests/db_functions/math/test_round.py5
-rw-r--r--tests/db_functions/math/test_sin.py5
-rw-r--r--tests/db_functions/math/test_sqrt.py5
-rw-r--r--tests/db_functions/math/test_tan.py5
20 files changed, 116 insertions, 0 deletions
diff --git a/tests/db_functions/math/test_abs.py b/tests/db_functions/math/test_abs.py
index 484cd2e306..b87f6844bc 100644
--- a/tests/db_functions/math/test_abs.py
+++ b/tests/db_functions/math/test_abs.py
@@ -10,6 +10,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class AbsTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_abs=Abs('normal')).first()
+ self.assertIsNone(obj.null_abs)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-0.8'), n2=Decimal('1.2'))
obj = DecimalModel.objects.annotate(n1_abs=Abs('n1'), n2_abs=Abs('n2')).first()
diff --git a/tests/db_functions/math/test_acos.py b/tests/db_functions/math/test_acos.py
index a9ba079e4f..04fdf2cf40 100644
--- a/tests/db_functions/math/test_acos.py
+++ b/tests/db_functions/math/test_acos.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class ACosTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_acos=ACos('normal')).first()
+ self.assertIsNone(obj.null_acos)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-0.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_acos=ACos('n1'), n2_acos=ACos('n2')).first()
diff --git a/tests/db_functions/math/test_asin.py b/tests/db_functions/math/test_asin.py
index dc135a6786..a9074e4305 100644
--- a/tests/db_functions/math/test_asin.py
+++ b/tests/db_functions/math/test_asin.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class ASinTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_asin=ASin('normal')).first()
+ self.assertIsNone(obj.null_asin)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('0.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_asin=ASin('n1'), n2_asin=ASin('n2')).first()
diff --git a/tests/db_functions/math/test_atan.py b/tests/db_functions/math/test_atan.py
index 36c07ae306..fbeeded48c 100644
--- a/tests/db_functions/math/test_atan.py
+++ b/tests/db_functions/math/test_atan.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class ATanTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_atan=ATan('normal')).first()
+ self.assertIsNone(obj.null_atan)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_atan=ATan('n1'), n2_atan=ATan('n2')).first()
diff --git a/tests/db_functions/math/test_atan2.py b/tests/db_functions/math/test_atan2.py
index 195892dfdd..ca12e64479 100644
--- a/tests/db_functions/math/test_atan2.py
+++ b/tests/db_functions/math/test_atan2.py
@@ -9,6 +9,15 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class ATan2Tests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create(big=100)
+ obj = IntegerModel.objects.annotate(
+ null_atan2_sn=ATan2('small', 'normal'),
+ null_atan2_nb=ATan2('normal', 'big'),
+ ).first()
+ self.assertIsNone(obj.null_atan2_sn)
+ self.assertIsNone(obj.null_atan2_nb)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-9.9'), n2=Decimal('4.6'))
obj = DecimalModel.objects.annotate(n_atan2=ATan2('n1', 'n2')).first()
diff --git a/tests/db_functions/math/test_ceil.py b/tests/db_functions/math/test_ceil.py
index a62c33a19f..af4ee44e31 100644
--- a/tests/db_functions/math/test_ceil.py
+++ b/tests/db_functions/math/test_ceil.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class CeilTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_ceil=Ceil('normal')).first()
+ self.assertIsNone(obj.null_ceil)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_ceil=Ceil('n1'), n2_ceil=Ceil('n2')).first()
diff --git a/tests/db_functions/math/test_cos.py b/tests/db_functions/math/test_cos.py
index 15975e247d..99cf96620e 100644
--- a/tests/db_functions/math/test_cos.py
+++ b/tests/db_functions/math/test_cos.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class CosTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_cos=Cos('normal')).first()
+ self.assertIsNone(obj.null_cos)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_cos=Cos('n1'), n2_cos=Cos('n2')).first()
diff --git a/tests/db_functions/math/test_cot.py b/tests/db_functions/math/test_cot.py
index 0407f3b45d..5af0403221 100644
--- a/tests/db_functions/math/test_cot.py
+++ b/tests/db_functions/math/test_cot.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class CotTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_cot=Cot('normal')).first()
+ self.assertIsNone(obj.null_cot)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_cot=Cot('n1'), n2_cot=Cot('n2')).first()
diff --git a/tests/db_functions/math/test_degrees.py b/tests/db_functions/math/test_degrees.py
index e5a551992f..a474d276a5 100644
--- a/tests/db_functions/math/test_degrees.py
+++ b/tests/db_functions/math/test_degrees.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class DegreesTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_degrees=Degrees('normal')).first()
+ self.assertIsNone(obj.null_degrees)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_degrees=Degrees('n1'), n2_degrees=Degrees('n2')).first()
diff --git a/tests/db_functions/math/test_exp.py b/tests/db_functions/math/test_exp.py
index 0981d4fce3..fac2f6c08d 100644
--- a/tests/db_functions/math/test_exp.py
+++ b/tests/db_functions/math/test_exp.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class ExpTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_exp=Exp('normal')).first()
+ self.assertIsNone(obj.null_exp)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_exp=Exp('n1'), n2_exp=Exp('n2')).first()
diff --git a/tests/db_functions/math/test_floor.py b/tests/db_functions/math/test_floor.py
index ee567cfea6..0c193ef1af 100644
--- a/tests/db_functions/math/test_floor.py
+++ b/tests/db_functions/math/test_floor.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class FloorTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_floor=Floor('normal')).first()
+ self.assertIsNone(obj.null_floor)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_floor=Floor('n1'), n2_floor=Floor('n2')).first()
diff --git a/tests/db_functions/math/test_ln.py b/tests/db_functions/math/test_ln.py
index 96d4599bb3..3c690d56cc 100644
--- a/tests/db_functions/math/test_ln.py
+++ b/tests/db_functions/math/test_ln.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class LnTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_ln=Ln('normal')).first()
+ self.assertIsNone(obj.null_ln)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_ln=Ln('n1'), n2_ln=Ln('n2')).first()
diff --git a/tests/db_functions/math/test_log.py b/tests/db_functions/math/test_log.py
index 02cbe084d3..469bb7cd3a 100644
--- a/tests/db_functions/math/test_log.py
+++ b/tests/db_functions/math/test_log.py
@@ -9,6 +9,15 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class LogTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create(big=100)
+ obj = IntegerModel.objects.annotate(
+ null_log_small=Log('small', 'normal'),
+ null_log_normal=Log('normal', 'big'),
+ ).first()
+ self.assertIsNone(obj.null_log_small)
+ self.assertIsNone(obj.null_log_normal)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('12.9'), n2=Decimal('3.6'))
obj = DecimalModel.objects.annotate(n_log=Log('n1', 'n2')).first()
diff --git a/tests/db_functions/math/test_mod.py b/tests/db_functions/math/test_mod.py
index 0e90175ddc..dc363432b7 100644
--- a/tests/db_functions/math/test_mod.py
+++ b/tests/db_functions/math/test_mod.py
@@ -9,6 +9,15 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class ModTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create(big=100)
+ obj = IntegerModel.objects.annotate(
+ null_mod_small=Mod('small', 'normal'),
+ null_mod_normal=Mod('normal', 'big'),
+ ).first()
+ self.assertIsNone(obj.null_mod_small)
+ self.assertIsNone(obj.null_mod_normal)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-9.9'), n2=Decimal('4.6'))
obj = DecimalModel.objects.annotate(n_mod=Mod('n1', 'n2')).first()
diff --git a/tests/db_functions/math/test_power.py b/tests/db_functions/math/test_power.py
index 01ca2b34d9..a2d6156e3d 100644
--- a/tests/db_functions/math/test_power.py
+++ b/tests/db_functions/math/test_power.py
@@ -8,6 +8,15 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class PowerTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create(big=100)
+ obj = IntegerModel.objects.annotate(
+ null_power_small=Power('small', 'normal'),
+ null_power_normal=Power('normal', 'big'),
+ ).first()
+ self.assertIsNone(obj.null_power_small)
+ self.assertIsNone(obj.null_power_normal)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('1.0'), n2=Decimal('-0.6'))
obj = DecimalModel.objects.annotate(n_power=Power('n1', 'n2')).first()
diff --git a/tests/db_functions/math/test_radians.py b/tests/db_functions/math/test_radians.py
index 873659e7ad..3c257bb278 100644
--- a/tests/db_functions/math/test_radians.py
+++ b/tests/db_functions/math/test_radians.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class RadiansTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_radians=Radians('normal')).first()
+ self.assertIsNone(obj.null_radians)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_radians=Radians('n1'), n2_radians=Radians('n2')).first()
diff --git a/tests/db_functions/math/test_round.py b/tests/db_functions/math/test_round.py
index d242f2de0f..4c2634c3c2 100644
--- a/tests/db_functions/math/test_round.py
+++ b/tests/db_functions/math/test_round.py
@@ -10,6 +10,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class RoundTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_round=Round('normal')).first()
+ self.assertIsNone(obj.null_round)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_round=Round('n1'), n2_round=Round('n2')).first()
diff --git a/tests/db_functions/math/test_sin.py b/tests/db_functions/math/test_sin.py
index 0f7e0c7c0b..f2e2edd4da 100644
--- a/tests/db_functions/math/test_sin.py
+++ b/tests/db_functions/math/test_sin.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class SinTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_sin=Sin('normal')).first()
+ self.assertIsNone(obj.null_sin)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_sin=Sin('n1'), n2_sin=Sin('n2')).first()
diff --git a/tests/db_functions/math/test_sqrt.py b/tests/db_functions/math/test_sqrt.py
index 81f13361e1..0e6238a141 100644
--- a/tests/db_functions/math/test_sqrt.py
+++ b/tests/db_functions/math/test_sqrt.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class SqrtTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_sqrt=Sqrt('normal')).first()
+ self.assertIsNone(obj.null_sqrt)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_sqrt=Sqrt('n1'), n2_sqrt=Sqrt('n2')).first()
diff --git a/tests/db_functions/math/test_tan.py b/tests/db_functions/math/test_tan.py
index 82dcec94fc..6db760725b 100644
--- a/tests/db_functions/math/test_tan.py
+++ b/tests/db_functions/math/test_tan.py
@@ -11,6 +11,11 @@ from ..models import DecimalModel, FloatModel, IntegerModel
class TanTests(TestCase):
+ def test_null(self):
+ IntegerModel.objects.create()
+ obj = IntegerModel.objects.annotate(null_tan=Tan('normal')).first()
+ self.assertIsNone(obj.null_tan)
+
def test_decimal(self):
DecimalModel.objects.create(n1=Decimal('-12.9'), n2=Decimal('0.6'))
obj = DecimalModel.objects.annotate(n1_tan=Tan('n1'), n2_tan=Tan('n2')).first()