#NEWLINE# def test_use_inherited_queries( self ) : #NEWLINE# #INDENT# @ self . connection . register #NEWLINE# class A ( Document ) : #NEWLINE# #INDENT# __database__ = 'test' #NEWLINE# __collection__ = 'mongolite' #NEWLINE# structure = { #NEWLINE# #INDENT# '_type' : unicode , #NEWLINE# 'a' : { #NEWLINE# #INDENT# 'foo' : int , #NEWLINE# 'bar' : unicode , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# @ self . connection . register #NEWLINE# class B ( A ) : #NEWLINE# #INDENT# structure = { #NEWLINE# #INDENT# 'b' : { #NEWLINE# #INDENT# 'eggs' : float , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# doc_a = self . connection . A ( ) #NEWLINE# self . assertEqual ( doc_a [ '_type' ] , 'A' ) #NEWLINE# doc_a [ 'a' ] [ 'foo' ] = 3 #NEWLINE# doc_a [ 'a' ] [ 'bar' ] = 'Hello World' #NEWLINE# doc_a . save ( ) #NEWLINE# doc_b = self . connection . B ( ) #NEWLINE# self . assertEqual ( doc_b [ '_type' ] , 'B' ) #NEWLINE# doc_b [ 'a' ] [ 'foo' ] = 42 #NEWLINE# doc_b [ 'a' ] [ 'bar' ] = 'bye bye' #NEWLINE# doc_b [ 'b' ] [ 'eggs' ] = 3.14 #NEWLINE# doc_b . save ( ) #NEWLINE# self . assertTrue ( isinstance ( self . connection . A . find_one ( { #NEWLINE# #INDENT# '_id' : doc_b [ '_id' ] , #NEWLINE# #UNINDENT# } ) , B ) ) #NEWLINE# self . assertTrue ( isinstance ( self . connection . A . find ( { #NEWLINE# #INDENT# '_id' : doc_b [ '_id' ] , #NEWLINE# #UNINDENT# } ) . next ( ) , B ) ) #NEWLINE# self . assertTrue ( isinstance ( self . connection . A . find ( { #NEWLINE# #INDENT# '_id' : doc_a [ '_id' ] , #NEWLINE# #UNINDENT# } ) [ 0 ] , B ) )