Example: 

I have an app that uses ContentType and I want to test that against an 
arbitrary model to make sure that the usage of ContentType is correct.


Ex:

In my app.models I have:

class Rating(models.Model): 
  total = models.DecimalField(default=0, decimal_places=2, max_digits=8)
  score = models.DecimalField(default=decimal.Decimal('0.00'), 
decimal_places=2, max_digits=6)
  votes = models.IntegerField(max_length=6, default=0, blank=True)
    
class RatedItem(models.Model):
  user = models.ForeignKey(User, related_name="RatedItem_User")
  content_type = models.ForeignKey(ContentType, related_name="RatedItem")
  object_id = models.PositiveIntegerField()
  item = generic.GenericForeignKey('content_type', 'object_id')


RatedItem is used to check if the user has rated an item already. For testing, 
I would like to have something like:

class TestItem(models.Model):
  name = models.CharField(max_length=20)
  rating = models.ForeignKey(Rating)

I don't want to clutter up my apps model.py with testing only stuff, that 
might confuse/encourage devs to do the wrong thing.

django-tagging gives the example, have a tests directory in your app, with 
__init__.py, tests.py , models.py, a settings.py with db info and an installed 
apps settings, that has only django.contrib.contentypes, tagging and 
tagging.tests.  OK I get this is the setup (mostly, the env variables in 
settings.py are rather annoying, but understandable). but two things about 
this bother me. 

A. How do the tests know to look for this setup and use the settings/model 
supplied?

B. Where is it documented?  (B. is the more important question)

I think way back something about this was mentioned on the list a long time 
ago. I rememeber a letter about tests/ or tests.py in apps. I just don't 
remember any information given on how to setup the testing environment this 
way, as it's own standalone app.

Also for south users/devs, how well does south cope with this situtaion?



Mike
-- 
Tcl tends to get ported to weird places like routers.
             -- Larry Wall in <199710071721.kaa19...@wall.org>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to