diff options
author | Nick Pope <nick.pope@flightdataservices.com> | 2020-07-16 23:32:46 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-10-02 06:58:03 +0200 |
commit | 06c5d3fafc6aeb96387148726713b611aeba7fa1 (patch) | |
tree | 80a366cad2aa8caf22062d6eb5f4487c36a000e2 /tests/db_functions | |
parent | f87b0ecd37e64e7a019d472de37d0789a8790f1f (diff) | |
download | django-06c5d3fafc6aeb96387148726713b611aeba7fa1.tar.gz |
Fixed #32060 -- Added Random database function.
Diffstat (limited to 'tests/db_functions')
-rw-r--r-- | tests/db_functions/math/test_random.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/db_functions/math/test_random.py b/tests/db_functions/math/test_random.py new file mode 100644 index 0000000000..6bcf49baf9 --- /dev/null +++ b/tests/db_functions/math/test_random.py @@ -0,0 +1,13 @@ +from django.db.models.functions import Random +from django.test import TestCase + +from ..models import FloatModel + + +class RandomTests(TestCase): + def test(self): + FloatModel.objects.create() + obj = FloatModel.objects.annotate(random=Random()).first() + self.assertIsInstance(obj.random, float) + self.assertGreaterEqual(obj.random, 0) + self.assertLess(obj.random, 1) |