#NEWLINE# def test_m2m_reverse_operations( self ) : #NEWLINE# #INDENT# 'M2M 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# mark = Person . objects . using ( 'other' ) . create ( name = 'Mark Pilgrim' ) #NEWLINE# dive . authors = [ mark ] #NEWLINE# grease = Book . objects . using ( 'other' ) . create ( title = 'Greasemonkey Hacks' , published = datetime . date ( 2005 , 11 , 1 ) ) #NEWLINE# mark . book_set . add ( grease ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( book__title = 'Dive into Python' ) . values_list ( 'name' , flat = True ) ) , [ 'Mark Pilgrim' ] ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( book__title = 'Greasemonkey Hacks' ) . values_list ( 'name' , flat = True ) ) , [ 'Mark Pilgrim' ] ) #NEWLINE# mark . book_set . remove ( grease ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( book__title = 'Dive into Python' ) . values_list ( 'name' , flat = True ) ) , [ 'Mark Pilgrim' ] ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( book__title = 'Greasemonkey Hacks' ) . values_list ( 'name' , flat = True ) ) , [ ] ) #NEWLINE# mark . book_set . clear ( ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( book__title = 'Dive into Python' ) . values_list ( 'name' , flat = True ) ) , [ ] ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( book__title = 'Greasemonkey Hacks' ) . values_list ( 'name' , flat = True ) ) , [ ] ) #NEWLINE# mark . book_set . create ( title = 'Dive into HTML5' , published = datetime . date ( 2020 , 1 , 1 ) ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( book__title = 'Dive into Python' ) . values_list ( 'name' , flat = True ) ) , [ ] ) #NEWLINE# self . assertEqual ( list ( Person . objects . using ( 'other' ) . filter ( book__title = 'Dive into HTML5' ) . values_list ( 'name' , flat = True ) ) , [ 'Mark Pilgrim' ] )