Esempio n. 1
0
    def test_vote_on_own_idea(self):
        from shootout.views import idea_vote
        from shootout.models import User

        self.config.include("shootout.addroutes")
        idea = self._addIdea()
        self.session.query(User).one()
        self.assertEqual(idea.user_voted(u"username"), False)
        self.config.testing_securitypolicy(u"username")
        post_data = {"form.vote_hit": u"Hit", "target": 1}
        request = testing.DummyRequest(post=post_data)
        idea_vote(request)
        self.assertEqual(idea.hits, 0)
        self.assertEqual(idea.misses, 0)
        self.assertEqual(idea.hit_percentage, 0)
        self.assertEqual(idea.total_votes, 0)
        self.assertEqual(idea.vote_differential, 0)
        self.assertEqual(idea.author.hits, 0)
        self.assertEqual(len(idea.voted_users.all()), 0)
        self.assertEqual(idea.user_voted(u"username"), False)
Esempio n. 2
0
    def test_negative_idea_voting(self):
        from shootout.views import idea_vote

        self.config.include("shootout.addroutes")
        user = self._addUser()
        idea = self._addIdea(user=user)
        voter = self._addUser(u"votername")
        self.assertEqual(idea.user_voted(u"votername"), False)
        self.config.testing_securitypolicy(u"votername")
        post_data = {"form.vote_miss": u"Miss", "target": 1}
        request = testing.DummyRequest(post=post_data)
        idea_vote(request)
        self.assertEqual(idea.hits, 0)
        self.assertEqual(idea.misses, 1)
        self.assertEqual(idea.hit_percentage, 0)
        self.assertEqual(idea.total_votes, 1)
        self.assertEqual(idea.vote_differential, -1)
        self.assertEqual(idea.author.hits, 0)
        self.assertEqual(len(idea.voted_users.all()), 1)
        self.assertEqual(idea.voted_users.one(), voter)
        self.assertTrue(idea.user_voted(u"votername"))
Esempio n. 3
0
 def test_vote_on_own_idea(self):
     from shootout.views import idea_vote
     from shootout.models import User
     _registerRoutes(self.config)
     idea = self._addIdea()
     self.session.query(User).one()
     self.assertEqual(idea.user_voted(u'username'), False)
     self.config.testing_securitypolicy(u'username')
     post_data = {
         'form.vote_hit': u'Hit',
         'target': 1,
     }
     request = testing.DummyRequest(post=post_data)
     idea_vote(request)
     self.assertEqual(idea.hits, 0)
     self.assertEqual(idea.misses, 0)
     self.assertEqual(idea.hit_percentage, 0)
     self.assertEqual(idea.total_votes, 0)
     self.assertEqual(idea.vote_differential, 0)
     self.assertEqual(idea.author.hits, 0)
     self.assertEqual(len(idea.voted_users.all()), 0)
     self.assertEqual(idea.user_voted(u'username'), False)
Esempio n. 4
0
 def test_vote_on_own_idea(self):
     from shootout.views import idea_vote
     from shootout.models import User
     self.config.include('shootout.addroutes')
     idea = self._addIdea()
     self.session.query(User).one()
     self.assertEqual(idea.user_voted(u'username'), False)
     self.config.testing_securitypolicy(u'username')
     post_data = {
         'form.vote_hit': u'Hit',
         'target': 1,
     }
     request = testing.DummyRequest(post=post_data)
     idea_vote(request)
     self.assertEqual(idea.hits, 0)
     self.assertEqual(idea.misses, 0)
     self.assertEqual(idea.hit_percentage, 0)
     self.assertEqual(idea.total_votes, 0)
     self.assertEqual(idea.vote_differential, 0)
     self.assertEqual(idea.author.hits, 0)
     self.assertEqual(len(idea.voted_users.all()), 0)
     self.assertEqual(idea.user_voted(u'username'), False)
Esempio n. 5
0
 def test_negative_idea_voting(self):
     from shootout.views import idea_vote
     _registerRoutes(self.config)
     user = self._addUser()
     idea = self._addIdea(user=user)
     voter = self._addUser(u'votername')
     self.assertEqual(idea.user_voted(u'votername'), False)
     self.config.testing_securitypolicy(u'votername')
     post_data = {
         'form.vote_miss': u'Miss',
         'target': 1,
     }
     request = testing.DummyRequest(post=post_data)
     idea_vote(request)
     self.assertEqual(idea.hits, 0)
     self.assertEqual(idea.misses, 1)
     self.assertEqual(idea.hit_percentage, 0)
     self.assertEqual(idea.total_votes, 1)
     self.assertEqual(idea.vote_differential, -1)
     self.assertEqual(idea.author.hits, 0)
     self.assertEqual(len(idea.voted_users.all()), 1)
     self.assertEqual(idea.voted_users.one(), voter)
     self.assertTrue(idea.user_voted(u'votername'))
Esempio n. 6
0
 def test_negative_idea_voting(self):
     from shootout.views import idea_vote
     self.config.include('shootout.addroutes')
     user = self._addUser()
     idea = self._addIdea(user=user)
     voter = self._addUser(u'votername')
     self.assertEqual(idea.user_voted(u'votername'), False)
     self.config.testing_securitypolicy(u'votername')
     post_data = {
         'form.vote_miss': u'Miss',
         'target': 1,
     }
     request = testing.DummyRequest(post=post_data)
     idea_vote(request)
     self.assertEqual(idea.hits, 0)
     self.assertEqual(idea.misses, 1)
     self.assertEqual(idea.hit_percentage, 0)
     self.assertEqual(idea.total_votes, 1)
     self.assertEqual(idea.vote_differential, -1)
     self.assertEqual(idea.author.hits, 0)
     self.assertEqual(len(idea.voted_users.all()), 1)
     self.assertEqual(idea.voted_users.one(), voter)
     self.assertTrue(idea.user_voted(u'votername'))
Esempio n. 7
0
 def test_negative_idea_voting(self):
     from shootout.views import idea_vote
     from shootout.models import User
     _registerRoutes(self.config)
     idea = self._addIdea()
     user = self.session.query(User).one()
     self.assertEqual(idea.user_voted('username'), False)
     self.config.testing_securitypolicy('username')
     post_data = {
         'form.vote_miss': u'Miss',
         'target': 1,
     }
     request = testing.DummyRequest(post=post_data)
     result = idea_vote(request)
     self.assertEqual(idea.hits, 0)
     self.assertEqual(idea.misses, 1)
     self.assertEqual(idea.hit_percentage, 0)
     self.assertEqual(idea.total_votes, 1)
     self.assertEqual(idea.vote_differential, -1)
     self.assertEqual(idea.author.hits, 0)
     self.assertEqual(len(idea.voted_users.all()), 1)
     self.assertEqual(idea.voted_users.one(), user)
     self.assertEqual(idea.user_voted('username'), True)