Django testing of multi-db with automatic routing -
simple problem - i'm using multi-db automatic routing setup documented on legacy db (which unmanaged). want test it. i've set testrunner around managed problem , can confirm creating databases , expected.
my problem database routing still trying @ non-test database. how can setup routers.py file @ test_ database when in test mode , non-test database other time.
should simple i'm beating head on wall on one..
fwiw:
class pmcatalogrouter(object): """a router control database operations on models in pmcatalog application""" def db_for_read(self, model, **hints): "point operations on pmcatalog models 'catalog'" if model._meta.app_label == 'pmcatalog': return 'catalog' return none def db_for_write(self, model, **hints): "point operations on pmcatalog models 'catalog'" if model._meta.app_label == 'pmcatalog': return 'catalog' return none def allow_syncdb(self, db, model): "make sure pmcatalog app appears on 'catalog' db" if db == 'catalog': return model._meta.app_label == 'pmcatalog' elif model._meta.app_label == 'pmcatalog': return false return none
much appreciate additional eyeballs on ;)
thanks
ok - here's happened. turns out working along, 2 separate issues caused tests passing. in case testing django query methods against legacy methods. wasn't passing test because legacy methods not looking @ test database rather original database. fixed problem , realized procedures not getting created in testrunner.
once these 2 problems corrected magically fell together...
hth someone.
Comments
Post a Comment