def test_has_user_voted_for_song(self): vote_service = VoteService() vote = Vote() vote.user_id = 1 vote.song_id = 1 vote.created_date = datetime.now() vote.like = True vote.save() user = User() user.id = 1 song = Song song.id = 1 self.assertTrue(vote_service.has_user_voted_for_song(song, user))
def create_votes(): Vote.objects.all().delete() for pk, fields in votos.iteritems(): try: v = Vote(pk=pk) v.user_id = get_user(fields['user']) v.value = fields['value'] v.content_object = Dateo.objects.get(pk=fields['object_id']) v.object_id = fields['object_id'] v.client_domain = datea v.save() created = date_parser(fields['created']) Vote.objects.filter(pk=v.pk).update(created=created) except: pass