Skip to content

Commit 412c1bb

Browse files
committed
Fix multiple_database test. Creating relationship to unsaved instance is no longer allowed
1 parent 577ec5e commit 412c1bb

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

tests/multiple_database/tests.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -301,30 +301,20 @@ def test_o2o_cross_database_protection(self):
301301
bob_profile = UserProfile.objects.using('other').create(user=bob, flavor='crunchy frog')
302302

303303
new_bob_profile = UserProfile(flavor="spring surprise")
304+
new_bob_profile.save(using='other')
304305

305306
charlie = User(username='charlie',email='[email protected]')
306307
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')
311309

312310
# old object comes from 'other', so the new object is set to use 'other'...
313311
new_bob_profile.user = bob
314312
charlie.userprofile = bob_profile
315313
self.assertEqual(new_bob_profile._state.db, 'other')
316314
self.assertEqual(charlie._state.db, 'other')
317315

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-
324316
# When saved (no using required), new objects goes to 'other'
325-
charlie.save()
326317
bob_profile.save()
327-
new_bob_profile.save()
328318
self.assertEqual(list(User.objects.using('default').values_list('username',flat=True)),
329319
[u'alice'])
330320
self.assertEqual(list(User.objects.using('other').values_list('username',flat=True)),

0 commit comments

Comments
 (0)