#NEWLINE# def test_create_properly_creates_new_model( self ) : #NEWLINE# #INDENT# relation = self . _get_relation ( ) #NEWLINE# created = flexmock ( Model ( ) , save = ( lambda : True ) , set_attribute = ( lambda : None ) ) #NEWLINE# created . should_receive ( 'save' ) . once ( ) . and_return ( True ) #NEWLINE# relation . get_related ( ) . should_receive ( 'new_instance' ) . once ( ) . with_args ( { #NEWLINE# #INDENT# 'name' : 'john' , #NEWLINE# #UNINDENT# } ) . and_return ( created ) #NEWLINE# created . should_receive ( 'set_attribute' ) . with_args ( 'foreign_key' , 1 ) #NEWLINE# self . assertEqual ( created , relation . create ( name = 'john' ) )