Django: How to create a model dynamically just for testing

Posted by muhuk on Stack Overflow See other posts from Stack Overflow or by muhuk
Published on 2009-02-02T11:35:52Z Indexed on 2010/04/20 4:03 UTC
Read the original article Hit count: 348

I have a Django app that requires a settings attribute in the form of:

RELATED_MODELS = ('appname1.modelname1.attribute1',
                  'appname1.modelname2.attribute2', 
                  'appname2.modelname3.attribute3', ...)

Then hooks their post_save signal to update some other fixed model depending on the attributeN defined.

I would like to test this behaviour and tests should work even if this app is the only one in the project (except for its own dependencies, no other wrapper app need to be installed). How can I create and attach/register/activate mock models just for the test database? (or is it possible at all?)

Solutions that allow me to use test fixtures would be great.

© Stack Overflow or respective owner

Related posts about python

Related posts about django