@@ -301,30 +301,20 @@ def test_o2o_cross_database_protection(self):
301
301
bob_profile = UserProfile .objects .using ('other' ).create (user = bob , flavor = 'crunchy frog' )
302
302
303
303
new_bob_profile = UserProfile (flavor = "spring surprise" )
304
+ new_bob_profile .save (using = 'other' )
304
305
305
306
charlie = User (
username = 'charlie' ,
email = '[email protected] ' )
306
307
charlie .set_unusable_password ()
307
-
308
- # initially, no db assigned
309
- self .assertEqual (new_bob_profile ._state .db , None )
310
- self .assertEqual (charlie ._state .db , None )
308
+ charlie .save (using = 'other' )
311
309
312
310
# old object comes from 'other', so the new object is set to use 'other'...
313
311
new_bob_profile .user = bob
314
312
charlie .userprofile = bob_profile
315
313
self .assertEqual (new_bob_profile ._state .db , 'other' )
316
314
self .assertEqual (charlie ._state .db , 'other' )
317
315
318
- # ... but it isn't saved yet
319
- self .assertEqual (list (User .objects .using ('other' ).values_list ('username' ,flat = True )),
320
- [u'bob' ])
321
- self .assertEqual (list (UserProfile .objects .using ('other' ).values_list ('flavor' ,flat = True )),
322
- [u'crunchy frog' ])
323
-
324
316
# When saved (no using required), new objects goes to 'other'
325
- charlie .save ()
326
317
bob_profile .save ()
327
- new_bob_profile .save ()
328
318
self .assertEqual (list (User .objects .using ('default' ).values_list ('username' ,flat = True )),
329
319
[u'alice' ])
330
320
self .assertEqual (list (User .objects .using ('other' ).values_list ('username' ,flat = True )),
0 commit comments