<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> import random <EOL> from django . test import TestCase <EOL> from django . contrib . auth . models import User <EOL> from updown . models import SCORE_TYPES <EOL> from updown . exceptions import CannotChangeVote <EOL> from tests . models import RatingTestModel <EOL> class TestRatingModel ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . instance = RatingTestModel . objects . create ( ) <EOL> self . user = User . objects . create ( <EOL> username = str ( random . randint ( <NUM_LIT:0> , <NUM_LIT> ) ) <EOL> ) <EOL> self . user2 = User . objects . create ( <EOL> username = str ( random . randint ( <NUM_LIT:0> , <NUM_LIT> ) ) <EOL> ) <EOL> def test_basic_vote ( self ) : <EOL> """<STR_LIT>""" <EOL> self . instance . rating . add ( SCORE_TYPES [ '<STR_LIT>' ] , self . user , <EOL> '<STR_LIT>' ) <EOL> self . assertEquals ( self . instance . rating_likes , <NUM_LIT:1> ) <EOL> def test_change_vote ( self ) : <EOL> self . instance . rating . add ( SCORE_TYPES [ '<STR_LIT>' ] , self . user , <EOL> '<STR_LIT>' ) <EOL> self . instance . rating . add ( SCORE_TYPES [ '<STR_LIT>' ] , self . user , <EOL> '<STR_LIT>' ) <EOL> self . assertEquals ( self . instance . rating_likes , <NUM_LIT:0> ) <EOL> self . assertEquals ( self . instance . rating_dislikes , <NUM_LIT:1> ) <EOL> def test_change_vote_disallowed ( self ) : <EOL> self . instance . rating2 . add ( SCORE_TYPES [ '<STR_LIT>' ] , self . user , <EOL> '<STR_LIT>' ) <EOL> self . assertRaises ( CannotChangeVote , self . instance . rating2 . add , <EOL> SCORE_TYPES [ '<STR_LIT>' ] , self . user , '<STR_LIT>' ) </s>
