mirror of
https://github.com/django/django.git
synced 2025-07-17 02:05:18 +00:00
Fixed #27996 -- Added RandomUUID function and CryptoExtension to contrib.postgres.
This commit is contained in:
parent
98ee57e343
commit
fcb5dbfec0
9 changed files with 81 additions and 5 deletions
|
@ -1,10 +1,11 @@
|
|||
import uuid
|
||||
from datetime import datetime
|
||||
from time import sleep
|
||||
|
||||
from django.contrib.postgres.functions import TransactionNow
|
||||
from django.contrib.postgres.functions import RandomUUID, TransactionNow
|
||||
|
||||
from . import PostgreSQLTestCase
|
||||
from .models import NowTestModel
|
||||
from .models import NowTestModel, UUIDTestModel
|
||||
|
||||
|
||||
class TestTransactionNow(PostgreSQLTestCase):
|
||||
|
@ -26,3 +27,15 @@ class TestTransactionNow(PostgreSQLTestCase):
|
|||
|
||||
self.assertIsInstance(m1.when, datetime)
|
||||
self.assertEqual(m1.when, m2.when)
|
||||
|
||||
|
||||
class TestRandomUUID(PostgreSQLTestCase):
|
||||
|
||||
def test_random_uuid(self):
|
||||
m1 = UUIDTestModel.objects.create()
|
||||
m2 = UUIDTestModel.objects.create()
|
||||
UUIDTestModel.objects.update(uuid=RandomUUID())
|
||||
m1.refresh_from_db()
|
||||
m2.refresh_from_db()
|
||||
self.assertIsInstance(m1.uuid, uuid.UUID)
|
||||
self.assertNotEqual(m1.uuid, m2.uuid)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue