#NEWLINE# def test_extra_method( self ) : #NEWLINE# #INDENT# self . create_model2abcd ( ) #NEWLINE# objects = list ( Model2A . objects . extra ( where = [ 'id IN (2, 3)' ] ) ) #NEWLINE# self . assertEqual ( repr ( objects [ 0 ] ) , '<Model2B: id 2, field1 (CharField), field2 (CharField)>' ) #NEWLINE# self . assertEqual ( repr ( objects [ 1 ] ) , '<Model2C: id 3, field1 (CharField), field2 (CharField), field3 (CharField)>' ) #NEWLINE# objects = Model2A . objects . extra ( select = { #NEWLINE# #INDENT# 'select_test' : "field1 = 'A1'" , #NEWLINE# #UNINDENT# } , where = [ "field1 = 'A1' OR field1 = 'B1'" ] , order_by = [ '-id' ] ) #NEWLINE# self . assertEqual ( repr ( objects [ 0 ] ) , '<Model2B: id 2, field1 (CharField), field2 (CharField) - Extra: select_test (int)>' ) #NEWLINE# self . assertEqual ( repr ( objects [ 1 ] ) , '<Model2A: id 1, field1 (CharField) - Extra: select_test (int)>' ) #NEWLINE# self . assertEqual ( len ( objects ) , 2 ) #NEWLINE# ModelExtraA . objects . create ( field1 = 'A1' ) #NEWLINE# ModelExtraB . objects . create ( field1 = 'B1' , field2 = 'B2' ) #NEWLINE# ModelExtraC . objects . create ( field1 = 'C1' , field2 = 'C2' , field3 = 'C3' ) #NEWLINE# ModelExtraExternal . objects . create ( topic = 'extra1' ) #NEWLINE# ModelExtraExternal . objects . create ( topic = 'extra2' ) #NEWLINE# ModelExtraExternal . objects . create ( topic = 'extra3' ) #NEWLINE# objects = ModelExtraA . objects . extra ( tables = [ 'polymorphic_modelextraexternal' ] , select = { #NEWLINE# #INDENT# 'topic' : 'polymorphic_modelextraexternal.topic' , #NEWLINE# #UNINDENT# } , where = [ 'polymorphic_modelextraa.id = polymorphic_modelextraexternal.id' ] ) #NEWLINE# if six . PY3 : #NEWLINE# #INDENT# self . assertEqual ( repr ( self [ 0 ] ) , '<ModelExtraA: id 1, field1 (CharField) "A1" - Extra: topic (str) "extra1">' ) #NEWLINE# self . assertEqual ( repr ( objects [ 1 ] ) , '<ModelExtraB: id 2, field1 (CharField) "B1", field2 (CharField) "B2" - Extra: topic (str) "extra2">' ) #NEWLINE# self . assertEqual ( repr ( objects [ 2 ] ) , '<ModelExtraC: id 3, field1 (CharField) "C1", field2 (CharField) "C2", field3 (CharField) "C3" - Extra: topic (str) "extra3">' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertEqual ( repr ( objects [ 0 ] ) , '<ModelExtraA: id 1, field1 (CharField) "A1" - Extra: topic (unicode) "extra1">' ) #NEWLINE# self . assertEqual ( repr ( objects [ 1 ] ) , '<ModelExtraB: id 2, field1 (CharField) "B1", field2 (CharField) "B2" - Extra: topic (unicode) "extra2">' ) #NEWLINE# self . assertEqual ( repr ( objects [ 2 ] ) , '<ModelExtraC: id 3, field1 (CharField) "C1", field2 (CharField) "C2", field3 (CharField) "C3" - Extra: topic (unicode) "extra3">' ) #NEWLINE# #UNINDENT# self . assertEqual ( len ( objects ) , 3 )