#NEWLINE# def test_schemaless_with_required( self ) : #NEWLINE# #INDENT# @ self . connection . register #NEWLINE# class MyDoc ( Document ) : #NEWLINE# #INDENT# use_schemaless = True #NEWLINE# structure = { #NEWLINE# #INDENT# 'foo' : unicode , #NEWLINE# 'bar' : int , #NEWLINE# #UNINDENT# } #NEWLINE# required_fields = [ 'foo' ] #NEWLINE# #UNINDENT# doc = self . col . MyDoc ( ) #NEWLINE# self . assertEqual ( ( 'foo' in doc ) , True ) #NEWLINE# self . assertEqual ( ( 'bar' in doc ) , True ) #NEWLINE# self . assertEqual ( ( 'egg' in doc ) , False ) #NEWLINE# doc [ 'foo' ] = 'bla' #NEWLINE# doc [ 'bar' ] = 3 #NEWLINE# doc [ 'egg' ] = 9 #NEWLINE# doc . save ( ) #NEWLINE# doc = self . col . MyDoc ( ) #NEWLINE# doc . pop ( 'foo' ) #NEWLINE# doc [ 'bar' ] = 3 #NEWLINE# doc [ 'egg' ] = 9 #NEWLINE# self . assertRaises ( RequireFieldError , doc . save ) #NEWLINE# doc = self . col . find_one ( ) #NEWLINE# doc . pop ( 'foo' ) #NEWLINE# self . col . save ( doc ) #NEWLINE# doc = self . col . MyDoc . find_one ( ) #NEWLINE# self . assertEqual ( ( 'foo' in self ) , False ) #NEWLINE# self . assertEqual ( ( 'bar' in doc ) , True ) #NEWLINE# self . assertEqual ( ( 'egg' in doc ) , True ) #NEWLINE# doc [ 'bar' ] = 2 #NEWLINE# self . assertRaises ( RequireFieldError , doc . save ) #NEWLINE# doc [ 'foo' ] = 'arf' #NEWLINE# doc . save ( )