My project access two databases, one of which is remote and read-only. When 
running tests, Django wants to create a test_ copy of that db on the remote 
host, but of course it lacks permission (I lack write access to the entire 
db host). So I'm blocked from running *any* tests, even ones that don't 
involve models for the remote data.

I've come up with four possible solutions:

1) Tell Django's test runner to create the test version of that db locally, 
not on the remote host. However, the documentation 
<https://docs.djangoproject.com/en/1.7/ref/settings/#std:setting-DATABASE-TEST> 
doesn't indicate a way to use the TEST: {} dictionary to specify an 
alternate host. This would be my preferred approach, but it doesn't seem 
possible.

2) Use this 
<https://github.com/boldprogressives/django-testrunner-use_live_db> module, 
which tells the test runner to treat the read-only db "as-is" rather than 
creating a copy of it. I don't like this because of the risk that the db 
might one day NOT be read-only (it's been discussed in our org). And  the 
module is 3 years old without updates.

3) Use this <http://stackoverflow.com/a/27541865/8438> technique, where the 
read-only db is pop()'d off the settings, making Django effectively forget 
it exists during testing (but then of course I can't test any code that 
involves those models). I'm currently doing this just to get tests back on 
the rails, but it's obviously very limiting. 

4) Use this 
<https://dianinggalihyudono.wordpress.com/2013/06/15/django-unit-test-with-fixtures-on-multiple-databases-part-2/>
 
technique, which alters the routers configuration during testing.

Is there a preferred or recommended approach to this problem? 

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2d599e4b-d208-472f-9a62-fc9c187da1d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to