Skip to content

Commit 1098942

Browse files
committed
adding tests with uuid
1 parent 5a01b1d commit 1098942

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/test_hash_model.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import dataclasses
55
import datetime
66
import decimal
7+
import uuid
78
from collections import namedtuple
89
from typing import Dict, List, Optional, Set, Union
910
from unittest import mock
@@ -830,3 +831,13 @@ class TypeWithUnion(m.BaseHashModel):
830831
# Note - we will not be able to automatically serialize an int back to this union type,
831832
# since as far as we know from Redis this item is a string
832833
assert twu_int_rematerialized.pk == twu_int.pk
834+
835+
836+
@py_test_mark_asyncio
837+
async def test_type_with_uuid():
838+
class TypeWithUuid(HashModel):
839+
uuid: uuid.UUID
840+
841+
item = TypeWithUuid(uuid=uuid.uuid4())
842+
843+
await item.save()

tests/test_json_model.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import dataclasses
55
import datetime
66
import decimal
7+
import uuid
78
from collections import namedtuple
89
from typing import Dict, List, Optional, Set, Union
910
from unittest import mock
@@ -903,3 +904,13 @@ class TypeWithUnion(m.BaseJsonModel):
903904
isinstance(twu_int_rematerialized.field, int)
904905
and twu_int_rematerialized.pk == twu_int.pk
905906
)
907+
908+
909+
@py_test_mark_asyncio
910+
async def test_type_with_uuid():
911+
class TypeWithUuid(JsonModel):
912+
uuid: uuid.UUID
913+
914+
item = TypeWithUuid(uuid=uuid.uuid4())
915+
916+
await item.save()

0 commit comments

Comments
 (0)