#NEWLINE# def test_append_reorder( self ) : #NEWLINE# #INDENT# self . _setup ( ordering_list ( 'position' , count_from = 1 , reorder_on_append = True ) ) #NEWLINE# s1 = Slide ( 'Slide #1' ) #NEWLINE# self . assert_ ( ( not s1 . bullets ) ) #NEWLINE# self . assert_ ( ( len ( s1 . bullets ) == 0 ) ) #NEWLINE# s1 . bullets . append ( Bullet ( 's1/b1' ) ) #NEWLINE# self . assert_ ( s1 . bullets ) #NEWLINE# self . assert_ ( ( len ( s1 . bullets ) == 1 ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 0 ] . position == 1 ) ) #NEWLINE# s1 . bullets . append ( Bullet ( 's1/b2' ) ) #NEWLINE# self . assert_ ( ( len ( s1 . bullets ) == 2 ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 0 ] . position == 1 ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 1 ] . position == 2 ) ) #NEWLINE# bul = Bullet ( 's1/b100' ) #NEWLINE# bul . position = 100 #NEWLINE# s1 . bullets . append ( bul ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 0 ] . position == 1 ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 1 ] . position == 2 ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 2 ] . position == 3 ) ) #NEWLINE# s1 . bullets . append ( Bullet ( 's1/b4' ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 0 ] . position == 1 ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 1 ] . position == 2 ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 2 ] . position == 3 ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 3 ] . position == 4 ) ) #NEWLINE# s1 . bullets . _reorder ( ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 0 ] . position == 1 ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 1 ] . position == 2 ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 2 ] . position == 3 ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 3 ] . position == 4 ) ) #NEWLINE# s1 . bullets . _raw_append ( Bullet ( 'raw' ) ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 4 ] . position is None ) ) #NEWLINE# s1 . bullets . _reorder ( ) #NEWLINE# self . assert_ ( ( s1 . bullets [ 4 ] . position == 5 ) ) #NEWLINE# session = create_session ( ) #NEWLINE# session . add ( bul ) #NEWLINE# session . flush ( ) #NEWLINE# id = s1 . id #NEWLINE# session . expunge_all ( ) #NEWLINE# del s1 #NEWLINE# srt = session . query ( Slide ) . get ( id ) #NEWLINE# self . assert_ ( srt . bullets ) #NEWLINE# self . assert_ ( ( len ( srt . bullets ) == 5 ) ) #NEWLINE# titles = [ 's1/b1' , 's1/b2' , 's1/b100' , 's1/b4' , 'raw' ] #NEWLINE# found = [ b . text for b in srt . bullets ] #NEWLINE# eq_ ( titles , found ) #NEWLINE# srt . bullets . _raw_append ( Bullet ( 'raw2' ) ) #NEWLINE# srt . bullets [ ( - 1 ) ] . position = 6 #NEWLINE# session . flush ( ) #NEWLINE# session . expunge_all ( ) #NEWLINE# srt = session . query ( Slide ) . get ( id ) #NEWLINE# titles = [ 's1/b1' , 's1/b2' , 's1/b100' , 's1/b4' , 'raw' , 'raw2' ] #NEWLINE# found = [ b . text for b in srt . bullets ] #NEWLINE# eq_ ( titles , found )