#NEWLINE# def test_basic( self ) : #NEWLINE# #INDENT# pre_signals = ( len ( signals . pre_save . receivers ) , len ( signals . post_save . receivers ) , len ( signals . pre_delete . receivers ) , len ( signals . post_delete . receivers ) ) #NEWLINE# data = [ ] #NEWLINE# def pre_save_test( signal , sender , instance , **kwargs ) : #NEWLINE# #INDENT# data . append ( ( instance , kwargs . get ( 'raw' , False ) ) ) #NEWLINE# #UNINDENT# signals . pre_save . connect ( pre_save_test ) #NEWLINE# def post_save_test( signal , sender , instance , **kwargs ) : #NEWLINE# #INDENT# data . append ( ( instance , kwargs . get ( 'created' ) , kwargs . get ( 'raw' , False ) ) ) #NEWLINE# #UNINDENT# signals . post_save . connect ( post_save_test ) #NEWLINE# def pre_delete_test( signal , sender , instance , **kwargs ) : #NEWLINE# #INDENT# data . append ( ( instance , ( instance . id is None ) ) ) #NEWLINE# #UNINDENT# signals . pre_delete . connect ( pre_delete_test ) #NEWLINE# post_delete_test = PostDeleteHandler ( data ) #NEWLINE# signals . post_delete . connect ( post_delete_test ) #NEWLINE# p1 = Person ( first_name = 'John' , last_name = 'Smith' ) #NEWLINE# self . assertEqual ( data , [ ] ) #NEWLINE# p1 . save ( ) #NEWLINE# self . assertEqual ( data , [ ( p1 , False ) , ( p1 , True , False ) ] ) #NEWLINE# data [ : ] = [ ] #NEWLINE# p1 . first_name = 'Tom' #NEWLINE# p1 . save ( ) #NEWLINE# self . assertEqual ( data , [ ( p1 , False ) , ( p1 , False , False ) ] ) #NEWLINE# data [ : ] = [ ] #NEWLINE# p1 . save_base ( raw = True ) #NEWLINE# self . assertEqual ( data , [ ( p1 , True ) , ( p1 , False , True ) ] ) #NEWLINE# data [ : ] = [ ] #NEWLINE# p1 . delete ( ) #NEWLINE# self . assertEqual ( data , [ ( p1 , False ) , ( p1 , False ) ] ) #NEWLINE# data [ : ] = [ ] #NEWLINE# p2 = Person ( first_name = 'James' , last_name = 'Jones' ) #NEWLINE# p2 . id = 99999 #NEWLINE# p2 . save ( ) #NEWLINE# self . assertEqual ( data , [ ( p2 , False ) , ( p2 , True , False ) ] ) #NEWLINE# data [ : ] = [ ] #NEWLINE# p2 . id = 99998 #NEWLINE# p2 . save ( ) #NEWLINE# self . assertEqual ( data , [ ( p2 , False ) , ( p2 , True , False ) ] ) #NEWLINE# data [ : ] = [ ] #NEWLINE# p2 . delete ( ) #NEWLINE# self . assertEqual ( data , [ ( p2 , False ) , ( p2 , False ) ] ) #NEWLINE# self . assertQuerysetEqual ( Person . objects . all ( ) , [ 'James Jones' ] , unicode ) #NEWLINE# signals . post_delete . disconnect ( post_delete_test ) #NEWLINE# signals . pre_delete . disconnect ( pre_delete_test ) #NEWLINE# signals . post_save . disconnect ( post_save_test ) #NEWLINE# signals . pre_save . disconnect ( pre_save_test ) #NEWLINE# post_signals = ( len ( signals . pre_save . receivers ) , len ( signals . post_save . receivers ) , len ( signals . pre_delete . receivers ) , len ( signals . post_delete . receivers ) ) #NEWLINE# self . assertEqual ( pre_signals , post_signals )