#NEWLINE# def test_basic_morph_many_relationship( self ) : #NEWLINE# #INDENT# user = OratorTestUser . create ( email = 'john@doe.com' ) #NEWLINE# user . photos ( ) . create ( name = 'Avatar 1' ) #NEWLINE# user . photos ( ) . create ( name = 'Avatar 2' ) #NEWLINE# post = user . posts ( ) . create ( name = 'First Post' ) #NEWLINE# post . photos ( ) . create ( name = 'Hero 1' ) #NEWLINE# post . photos ( ) . create ( name = 'Hero 2' ) #NEWLINE# self . assertIsInstance ( user . photos , Collection ) #NEWLINE# self . assertIsInstance ( user . photos [ 0 ] , OratorTestPhoto ) #NEWLINE# self . assertIsInstance ( post . photos , Collection ) #NEWLINE# self . assertIsInstance ( post . photos [ 0 ] , OratorTestPhoto ) #NEWLINE# self . assertEqual ( 2 , len ( user . photos ) ) #NEWLINE# self . assertEqual ( 2 , len ( post . photos ) ) #NEWLINE# self . assertEqual ( 'Avatar 1' , user . photos [ 0 ] . name ) #NEWLINE# self . assertEqual ( 'Avatar 2' , user . photos [ 1 ] . name ) #NEWLINE# self . assertEqual ( 'Hero 1' , post . photos [ 0 ] . name ) #NEWLINE# self . assertEqual ( 'Hero 2' , post . photos [ 1 ] . name ) #NEWLINE# photos = OratorTestPhoto . order_by ( 'name' ) . get ( ) #NEWLINE# self . assertIsInstance ( photos , Collection ) #NEWLINE# self . assertEqual ( 4 , len ( photos ) ) #NEWLINE# self . assertIsInstance ( photos [ 0 ] . imageable , OratorTestUser ) #NEWLINE# self . assertIsInstance ( photos [ 2 ] . imageable , OratorTestPost ) #NEWLINE# self . assertEqual ( 'john@doe.com' , photos [ 1 ] . imageable . email ) #NEWLINE# self . assertEqual ( 'First Post' , photos [ 3 ] . imageable . name )