Created
February 9, 2017 16:45
-
-
Save NightBlues/111e1683e36d91ce5d44aba8564297a1 to your computer and use it in GitHub Desktop.
marshmallow mongoengine validate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_models(): | |
import models | |
from mongoengine.base.common import _document_registry | |
def _checker(model_class): | |
schema_class = getattr(model_class, 'schema_class', None) | |
return schema_class is not None and issubclass(schema_class, Schema) | |
return filter(_checker, _document_registry.values()) | |
@pytest.mark.parametrize('model', find_models()) | |
def test_schema_not_overlaps_model(model): | |
model_class = model | |
schema_class = model_class.schema_class | |
schema_fields = schema_class().declared_fields.keys() | |
model_fields = model_class._fields.keys() | |
assert set(schema_fields) == set(model_fields) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment