juanique/django-chocolate — pull request #12 by thagat (2012-12-20 15:28:25+00:00)
Title: Feature/colliding model names

Support for models with the same name
===============================

get_key
-----------

Now the generated key follows the following patter: "%(app_name).%(model_name)" in lowercase.

The name of the model is now also accepted as a key to get a mockup. If a second model with the same name is registered, then the model name will no longer work as a key and will throw a MultipleMockupsReturned exception. This was done for backwards compatibility, and to spare the user to write the name of the app if it's not necessary.

tests
------
Created the zombie_blog app, with the following models:
* Entry (Same name as blog.models.Entry)
* GuturalComment (Inherits from blog.models.Comment)
* User (Inhertis from django.contrib.auth.models.User and it has the same model name)

The new tests are as follows

* Checks Before registering the Entry model from the zombie_blog app, that UnregisteredModel is raised.. After registration, it checks that the 'entry' key is no longer valid and raises a MultipleMockupsReturned

* Test to validate that models inheriting from one to another are
correctly creating both the object and the parent model object

* Test to check if __get_item__ correctly throws exceptions when a model
inherits from another with the same name