Question

Our app has a specific behavior when the database is out of service. I want to write a test for this behavior but in can't find a solution.

I suppose the simplest way is to break database auth or name but :

override_settings can't change the DATABASE settings ( https://code.djangoproject.com/ticket/19031 )

modify_settings isn't implemented in django 1.6

There is a solution to do this ?

Thanks

Était-ce utile?

La solution

You can try closing your connection to the database in your test.

from django import db

from myapp.models import MyModel

# assuming only one connection
db.connections.all()[0].connection.close()

try:
    MyModel.objects.first()
except db.InterfaceError, e:
    print e
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top