Ticket #13724: 13724.routing_test.diff

File 13724.routing_test.diff, 962 bytes (added by Paul Collins, 11 years ago)

Test case showing the problem

  • tests/multiple_database/tests.py

    diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py
    index b1c0978..ee3efe7 100644
    a b class MigrateTestCase(TestCase):  
    19561956            router.routers = old_routers
    19571957
    19581958        self.assertEqual(cts.count(), 0)
     1959
     1960
     1961class RouteForWriteTestCase(TestCase):
     1962    multi_db = True
     1963
     1964    def test_delete_fk(self):
     1965        class Rtr(object):
     1966            def db_for_write(self, model, **hints):
     1967                raise AttributeError('Good')
     1968
     1969
     1970        owner = Person.objects.create(name='Someone')
     1971        try:
     1972            old_rtrs = router.routers
     1973            router.routers = [Rtr()]
     1974            to_del_qs = owner.pet_set.all()
     1975            to_del_qs.delete()
     1976            self.fail('Should have attempted to re-route to write db')
     1977        except AttributeError:
     1978            pass
     1979        finally:
     1980            router.routers = old_rtrs
Back to Top