tags:

views:

17

answers:

1

Guys,

I have installed django-ratings application in my django project.

Am wondering how best can i test my app voting functionality because django ratings is only allowing me to vote once for the same user, object and Ip address. Is there a way i can disable this checks so that i can just insert votes, test my application and when am happy i can enable this checks back. e.g. you can only run this once in the same machine;

myobject.rating.add(score=1, user='user_name', ip_address='127.0.0.1') 

Again the user need to have been authenticated, unless you use None, but again you can only vote once.

Gath

+1  A: 

You cannot 'disable' these checks because they're specified in the Vote model:

unique_together = (('content_type', 'object_id', 'key', 'user', 'ip_address'))

You could edit it but that'd be monkey-patching (and maybe would brake the app).

Consider writing tests, or if you just want to have some votes filled just for the purpose of development, use fixtures (which are also useful in tests).

zalew
Hmmm, thought so, started writing external testing app, that populates the necessary tables and fields. I wish Crammer would add some flag like "Development mode" and "production mode" would be nice. Thanks a lot.
gath