diff --git a/tests/model_fields_/test_objectidfield.py b/tests/model_fields_/test_objectidfield.py new file mode 100644 index 00000000..46c8566d --- /dev/null +++ b/tests/model_fields_/test_objectidfield.py @@ -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)