improvements of test coverage in fields

This commit is contained in:
Bastien Gerard
2020-12-18 00:05:28 +01:00
parent 9a3bca8ab6
commit 98d64f41c6
8 changed files with 169 additions and 112 deletions

View File

@@ -2,11 +2,28 @@ from decimal import Decimal
import pytest
from mongoengine import *
from mongoengine import (
CachedReferenceField,
DecimalField,
Document,
EmbeddedDocument,
EmbeddedDocumentField,
InvalidDocumentError,
ListField,
ReferenceField,
StringField,
ValidationError,
)
from tests.utils import MongoDBTestCase
class TestCachedReferenceField(MongoDBTestCase):
def test_constructor_fail_bad_document_type(self):
with pytest.raises(
ValidationError, match="must be a document class or a string"
):
CachedReferenceField(document_type=0)
def test_get_and_save(self):
"""
Tests #1047: CachedReferenceField creates DBRefs on to_python,