#NEWLINE# def test_form_onetoone( ) : #NEWLINE# #INDENT# ( app , db , admin ) = setup ( ) #NEWLINE# class Model1 ( db . Model ) : #NEWLINE# #INDENT# id = db . Column ( db . Integer , primary_key = True ) #NEWLINE# test = db . Column ( db . String ) #NEWLINE# #UNINDENT# class Model2 ( db . Model ) : #NEWLINE# #INDENT# id = db . Column ( db . Integer , primary_key = True ) #NEWLINE# model1_id = db . Column ( db . Integer , db . ForeignKey ( Model1 . id ) ) #NEWLINE# model1 = db . relationship ( Model1 , backref = db . backref ( 'model2' , uselist = False ) ) #NEWLINE# #UNINDENT# db . create_all ( ) #NEWLINE# view1 = CustomModelView ( Model1 , db . session , endpoint = 'view1' ) #NEWLINE# view2 = CustomModelView ( Model2 , db . session , endpoint = 'view2' ) #NEWLINE# admin . add_view ( view1 ) #NEWLINE# admin . add_view ( view2 ) #NEWLINE# model1 = Model1 ( test = 'test' ) #NEWLINE# model2 = Model2 ( model1 = model1 ) #NEWLINE# db . session . add ( model1 ) #NEWLINE# db . session . add ( model2 ) #NEWLINE# db . session . commit ( ) #NEWLINE# eq_ ( model1 . model2 , model2 ) #NEWLINE# eq_ ( model2 . model1 , model1 ) #NEWLINE# eq_ ( model2 . _create_form_class . model2 . kwargs [ 'widget' ] . multiple , False ) #NEWLINE# eq_ ( view2 . _create_form_class . model1 . kwargs [ 'widget' ] . multiple , False )