#NEWLINE# def test_foreign_key_reverse_operations( self ) : #NEWLINE# #INDENT# 'FK reverse manipulations are all constrained to a single DB' #NEWLINE# dive = Book . objects . using ( 'other' ) . create ( title = 'Dive into Python' , published = datetime . date ( 2009 , 5 , 4 ) ) #NEWLINE# chris = Person . objects . using ( 'other' ) . create ( name = 'Chris Mills' ) #NEWLINE# dive . editor = chris #NEWLINE# dive . save ( ) #NEWLINE# html5 = Book . objects . using ( 'other' ) . create ( title = 'Dive into HTML5' , published = datetime . date ( 2010 , 3 , 15 ) ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( edited__title = 'Dive into HTML5' ) . values_list ( 'name' , flat = True ) ) , [ ] ) #NEWLINE# chris . edited . add ( html5 ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( edited__title = 'Dive into HTML5' ) . values_list ( 'name' , flat = True ) ) , [ 'Chris Mills' ] ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( edited__title = 'Dive into Python' ) . values_list ( 'name' , flat = True ) ) , [ 'Chris Mills' ] ) #NEWLINE# chris . edited . remove ( html5 ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( edited__title = 'Dive into HTML5' ) . values_list ( 'name' , flat = True ) ) , [ ] ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( edited__title = 'Dive into Python' ) . values_list ( 'name' , flat = True ) ) , [ 'Chris Mills' ] ) #NEWLINE# chris . edited . clear ( ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( edited__title = 'Dive into HTML5' ) . values_list ( 'name' , flat = True ) ) , [ ] ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( edited__title = 'Dive into Python' ) . values_list ( 'name' , flat = True ) ) , [ ] ) #NEWLINE# chris . edited . create ( title = 'Dive into Water' , published = datetime . date ( 2010 , 3 , 15 ) ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( edited__title = 'Dive into HTML5' ) . values_list ( 'name' , flat = True ) ) , [ ] ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( edited__title = 'Dive into Water' ) . values_list ( 'name' , flat = True ) ) , [ 'Chris Mills' ] ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( edited__title = 'Dive into Python' ) . values_list ( 'name' , flat = True ) ) , [ ] )