Or, \"How to design your Database Schema for easy Unit testing?\"
By the way, there is a very similar question to this here: How to test Models in Django with Foreig
I'm not really sure if you need to go that deep. You should not design your software basing on how you want to test it, you need to adapt your way of testing to the tools you're using.
Say that you want to get that level of granularity, like mocking FK and M2M models when you test some model, right? Something like
class Invoice(models.Model):
client = models.ForeignKey(Client)
and in your tests, you want to test only Invoice
model, without dealing with Client
model. Is that right? So, why don't you mock the database backend too, and just test ONLY what your model should do?
My point is that you don't need to get to that level. Add some tests to your models for non-trivial things like signals, methods, check that the model creations are working (can even avoid this if you trust the database), and when you need to work with external models just create what you need on the test's setUp()
method.
Also if you want you can mock whatever you want using Python's mock library: http://www.voidspace.org.uk/python/mock/. If you really want to do TDD, you can use it for mock your FK in each test, but if you change that model, you will need to change all the mockers too.