1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
from django import test
from django.core import cache
class TestCase(test.TransactionTestCase):
def _pre_setup(self):
cache.cache.clear()
super()._pre_setup()
class ReplicationRouter:
"""Router for simulating an environment with DB replication
This router directs all DB reads to a completely different database than
writes. This can be useful for simulating an environment where DB
replication is delayed to identify potential race conditions.
"""
def db_for_read(self, model, **hints):
return 'readonly'
def db_for_write(self, model, **hints):
return 'default'
|