#NEWLINE# def test_o2o_separation( self ) : #NEWLINE# #INDENT# 'OneToOne fields are constrained to a single database' #NEWLINE# alice = User . objects . db_manager ( 'default' ) . create_user ( 'alice' , 'alice@example.com' ) #NEWLINE# alice_profile = UserProfile . objects . using ( 'default' ) . create ( user = alice , flavor = 'chocolate' ) #NEWLINE# bob = User . objects . db_manager ( 'other' ) . create_user ( 'bob' , 'bob@example.com' ) #NEWLINE# bob_profile = UserProfile . objects . using ( 'other' ) . create ( user = bob , flavor = 'crunchy frog' ) #NEWLINE# alice = User . objects . using ( 'default' ) . get ( username = 'alice' ) #NEWLINE# self . assertEqual ( alice . userprofile . flavor , 'chocolate' ) #NEWLINE# bob = User . objects . using ( 'other' ) . get ( username = 'bob' ) #NEWLINE# self . assertEqual ( bob . userprofile . flavor , 'crunchy frog' ) #NEWLINE# self . assertEqual ( list ( User . objects . using ( 'default' ) . filter ( userprofile__flavor = 'chocolate' ) . values_list ( 'username' , flat = True ) ) , [ 'alice' ] ) #NEWLINE# self . assertEqual ( list ( User . objects . using ( 'other' ) . filter ( userprofile__flavor = 'chocolate' ) . values_list ( 'username' , flat = True ) ) , [ ] ) #NEWLINE# self . assertEqual ( list ( User . objects . using ( 'default' ) . filter ( userprofile__flavor = 'crunchy frog' ) . values_list ( 'username' , flat = True ) ) , [ ] ) #NEWLINE# self . assertEqual ( list ( User . objects . using ( 'other' ) . filter ( userprofile__flavor = 'crunchy frog' ) . values_list ( 'username' , flat = True ) ) , [ 'bob' ] ) #NEWLINE# alice_profile = UserProfile . objects . using ( 'default' ) . get ( flavor = 'chocolate' ) #NEWLINE# bob_profile = UserProfile . objects . using ( 'other' ) . get ( flavor = 'crunchy frog' ) #NEWLINE# self . assertEqual ( alice_profile . user . username , 'alice' ) #NEWLINE# self . assertEqual ( bob_profile . user . username , 'bob' )