#NEWLINE# def test_foreign_key_cross_database_protection( self ) : #NEWLINE# #INDENT# 'Operations that involve sharing FK objects across databases raise an error' #NEWLINE# pro = Book . objects . create ( title = 'Pro Django' , published = datetime . date ( 2008 , 12 , 16 ) ) #NEWLINE# marty = Person . objects . create ( name = 'Marty Alchin' ) #NEWLINE# dive = Book . objects . using ( 'other' ) . create ( title = 'Dive into Python' , published = datetime . date ( 2009 , 5 , 4 ) ) #NEWLINE# with self . assertRaises ( ValueError ) : #NEWLINE# #INDENT# dive . editor = marty #NEWLINE# #UNINDENT# with self . assertRaises ( ValueError ) : #NEWLINE# #INDENT# with transaction . atomic ( using = 'default' ) : #NEWLINE# #INDENT# marty . edited . set ( [ pro , dive ] ) #NEWLINE# #UNINDENT# #UNINDENT# with self . assertRaises ( ValueError ) : #NEWLINE# #INDENT# with transaction . atomic ( using = 'default' ) : #NEWLINE# #INDENT# marty . edited . add ( dive )