summaryrefslogtreecommitdiff
path: root/tests/db_functions/math/test_pi.py
diff options
context:
space:
mode:
authorJunyi Jiao <jiaojunyi90@gmail.com>2018-07-05 11:02:12 -0400
committerTim Graham <timograham@gmail.com>2018-07-05 11:02:12 -0400
commita0b19a0f5b1731cf575546175034da53f5af5367 (patch)
tree912f6367180636e4c9e1aecc4045830046a70ea6 /tests/db_functions/math/test_pi.py
parent48aeca44d885929106e71fe78379fe50850af001 (diff)
Refs #28643 -- Added math database functions.
Thanks Nick Pope for much review.
Diffstat (limited to 'tests/db_functions/math/test_pi.py')
-rw-r--r--tests/db_functions/math/test_pi.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/db_functions/math/test_pi.py b/tests/db_functions/math/test_pi.py
new file mode 100644
index 0000000000..2446420fd3
--- /dev/null
+++ b/tests/db_functions/math/test_pi.py
@@ -0,0 +1,15 @@
+import math
+
+from django.db.models.functions import Pi
+from django.test import TestCase
+
+from ..models import FloatModel
+
+
+class PiTests(TestCase):
+
+ def test(self):
+ FloatModel.objects.create(f1=2.5, f2=15.9)
+ obj = FloatModel.objects.annotate(pi=Pi()).first()
+ self.assertIsInstance(obj.pi, float)
+ self.assertAlmostEqual(obj.pi, math.pi, places=5)