Skip to content

Commit

Permalink
Add tests for custom mapping in DocType
Browse files Browse the repository at this point in the history
  • Loading branch information
honzakral committed Jan 23, 2015
1 parent 0d6de74 commit 94e4241
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test_elasticsearch_dsl/test_document.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime

from elasticsearch_dsl import document, field
from elasticsearch_dsl import document, field, Mapping

class MyDoc(document.DocType):
title = field.String(index='not_analyzed')
Expand Down Expand Up @@ -59,6 +59,21 @@ def test_declarative_mapping_definition():
}
} == MyDoc._doc_type.mapping.to_dict()

def test_you_can_supply_own_mapping_instance():
class MyD(document.DocType):
title = field.String()

class Meta:
mapping = Mapping('my_d')
mapping = mapping.meta('_all', enabled=False)

assert {
'my_d': {
'_all': {'enabled': False},
'properties': {'title': {'type': 'string'}}
}
} == MyD._doc_type.mapping.to_dict()

def test_document_can_be_created_dynamicaly():
n = datetime.now()
md = MyDoc(title='hello')
Expand Down

0 comments on commit 94e4241

Please sign in to comment.