def test_document_schema_to_dict(): sample_json2 = json.dumps(ensure_key_order({ 'fields': {'email': {'type': 'nimoy.fields.TextField', 'required': True}}, 'indexes': [['email']], 'options': {}, })) schema = DocumentSchema.from_json(sample_json2) sample_dict = schema.to_dict() sample_json = schema.to_json() assert sample_dict is not None assert sample_dict['fields']['email']['type'] == 'nimoy.fields.TextField' assert sample_json == sample_json2
def to_dict(self): return ensure_key_order({ 'schemas': {sname: schema.to_dict() for sname, schema in self._schemas.items()}, 'options': self._options })
def to_dict(self): return ensure_key_order({ 'fields': {fname: self._field_ops_to_dict(fops) for fname, fops in self._fields.items()}, 'indexes': self._indexes, 'options': self._options })