'Operations that involve sharing FK objects across databases raise an error'

def test_foreign_key_cross_database_protection(self):

    pro = Book.objects.create(title='Pro    Django', published=datetime.date(2008, 12, 16))
    marty = Person.objects.create(name='Marty    Alchin')
    dive = Book.objects.using('other').create(title='Dive    into    Python', published=datetime.date(2009, 5, 4))
    msg = 'Cannot    assign    "<Person:    Marty    Alchin>":    the    current    database    router    prevents    this    relation.'
    with self.assertRaisesMessage(ValueError, msg):
        dive.editor = marty
    with self.assertRaisesMessage(ValueError, msg):
        with transaction.atomic(using='default'):
            marty.edited.set([pro, dive])
    with self.assertRaisesMessage(ValueError, msg):
        with transaction.atomic(using='default'):
            marty.edited.add(dive)
