Skip to content

Commit

Permalink
Add ObjectIdField unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
WaVEV committed Nov 19, 2024
1 parent 1c1a947 commit 0570518
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/model_fields_/test_objectidfield.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from bson import ObjectId
from django.test import SimpleTestCase

from django_mongodb.fields import ObjectIdField


class MethodTests(SimpleTestCase):
def test_deconstruct(self):
field = ObjectIdField()
name, path, args, kwargs = field.deconstruct()
self.assertEqual(path, "django_mongodb.fields.ObjectIdField")
self.assertEqual(args, [])
self.assertEqual(kwargs, {})

def test_get_internal_type(self):
f = ObjectIdField()
self.assertEqual(f.get_internal_type(), "ObjectIdField")

def test_to_python(self):
f = ObjectIdField()
expected = ObjectId("1" * 24)
self.assertEqual(f.to_python("1" * 24), expected)
self.assertEqual(f.to_python(expected), expected)

0 comments on commit 0570518

Please sign in to comment.