Permalink
Browse files

tests update

  • Loading branch information...
1 parent 97b688d commit e375a94d1e6fcfea02b65b395ecc30dbdfd0c734 @last-partizan last-partizan committed Feb 4, 2016
Showing with 22 additions and 2 deletions.
  1. +1 −1 setup.cfg
  2. +9 −0 tests/forms/models.py
  3. +10 −0 tests/forms/tests.py
  4. +2 −1 tests/settings.py
View
@@ -9,4 +9,4 @@ cover-erase = 1
cover-html = 1
cover-html-dir = ../htmlcov
cover-package = django_mongoengine
-where = ./tests
+tests = tests
@@ -0,0 +1,9 @@
+from django.db import models
+from django_mongoengine import fields, Document
+
+class MongoDoc(Document):
+ intfield = fields.IntField()
+
+
+class DjangoModel(models.Model):
+ intfield = models.IntegerField()
View
@@ -4,8 +4,10 @@
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
+from django.forms.models import modelform_factory
from tests import MongoTestCase
+from django_mongoengine.forms.documents import documentform_factory
from django_mongoengine.forms.fields import DictField
from django_mongoengine.forms import widgets
@@ -259,3 +261,11 @@ def _check_structure(self, widget, structure, hint, level=0):
'{hint}:{level}: widget: {widget} should be a {cls}'.format(**{
"hint": hint, "widget": widget, "cls": wclass, "level": level,
}))
+
+class FormFactoryTest(MongoTestCase):
+
+ def test_documentform_factory(self):
+ from .models import MongoDoc, DjangoModel
+ m_form = documentform_factory(MongoDoc, fields="__all__")()
+ d_form = modelform_factory(DjangoModel, fields="__all__")()
+ self.assertEqual(d_form.as_p(), m_form.as_p())
View
@@ -102,7 +102,8 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'django_mongoengine',
- 'tests.views'
+ 'tests.views',
+ 'tests.forms',
)

0 comments on commit e375a94

Please sign in to comment.