django-model-utils/tests/test_models/test_uuid_model.py
Maarten ter Huurne aeeb69a9dd Enable postponed evaluation of annotations for all test modules
This allows using the latest annotation syntax supported by the type
checker regardless of the runtime Python version.
2024-06-13 12:02:05 +02:00

20 lines
673 B
Python

from __future__ import annotations
from django.test import TestCase
from tests.models import CustomNotPrimaryUUIDModel, CustomUUIDModel
class UUIDFieldTests(TestCase):
def test_uuid_model_with_uuid_field_as_primary_key(self):
instance = CustomUUIDModel()
instance.save()
self.assertEqual(instance.id.__class__.__name__, 'UUID')
self.assertEqual(instance.id, instance.pk)
def test_uuid_model_with_uuid_field_as_not_primary_key(self):
instance = CustomNotPrimaryUUIDModel()
instance.save()
self.assertEqual(instance.uuid.__class__.__name__, 'UUID')
self.assertNotEqual(instance.uuid, instance.pk)