mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #32060 -- Added Random database function.
This commit is contained in:
committed by
Mariusz Felisiak
parent
f87b0ecd37
commit
06c5d3fafc
13
tests/db_functions/math/test_random.py
Normal file
13
tests/db_functions/math/test_random.py
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user