#NEWLINE# def test_basic( self ) : #NEWLINE# #INDENT# a1 = Article . objects . create ( headline = 'Article 1' , pub_date = datetime ( 2005 , 7 , 26 ) ) #NEWLINE# a2 = Article . objects . create ( headline = 'Article 2' , pub_date = datetime ( 2005 , 7 , 27 ) ) #NEWLINE# a3 = Article . objects . create ( headline = 'Article 3' , pub_date = datetime ( 2005 , 7 , 27 ) ) #NEWLINE# a4 = Article . objects . create ( headline = 'Article 4' , pub_date = datetime ( 2005 , 7 , 28 ) ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . all ( ) , [ 'Article 4' , 'Article 2' , 'Article 3' , 'Article 1' ] , attrgetter ( 'headline' ) ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . order_by ( 'headline' ) , [ 'Article 1' , 'Article 2' , 'Article 3' , 'Article 4' ] , attrgetter ( 'headline' ) ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . order_by ( 'pub_date' , '-headline' ) , [ 'Article 1' , 'Article 3' , 'Article 2' , 'Article 4' ] , attrgetter ( 'headline' ) ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . order_by ( 'id' ) , [ 'Article 1' , 'Article 2' , 'Article 3' , 'Article 4' ] , attrgetter ( 'headline' ) ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . order_by ( 'id' ) . order_by ( '-headline' ) , [ 'Article 4' , 'Article 3' , 'Article 2' , 'Article 1' ] , attrgetter ( 'headline' ) ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . order_by ( 'headline' ) [ : 2 ] , [ 'Article 1' , 'Article 2' ] , attrgetter ( 'headline' ) ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . order_by ( 'headline' ) [ 1 : 3 ] , [ 'Article 2' , 'Article 3' ] , attrgetter ( 'headline' ) ) #NEWLINE# self . assertEqual ( Article . objects . all ( ) [ 0 ] , a1 ) #NEWLINE# self . assertEqual ( len ( list ( Article . objects . order_by ( '?' ) ) ) , 4 ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . all ( ) . reverse ( ) [ : 2 ] , [ 'Article 1' , 'Article 3' ] , attrgetter ( 'headline' ) ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . extra ( select = { #NEWLINE# #INDENT# 'foo' : 'pub_date' , #NEWLINE# #UNINDENT# } , order_by = [ 'foo' , 'headline' ] ) , [ 'Article 1' , 'Article 2' , 'Article 3' , 'Article 4' ] , attrgetter ( 'headline' ) ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . extra ( select = { #NEWLINE# #INDENT# 'order' : 'pub_date' , #NEWLINE# #UNINDENT# } , order_by = [ 'order' , 'headline' ] ) , [ 'Article 1' , 'Article 2' , 'Article 3' , 'Article 4' ] , attrgetter ( 'headline' ) )