Example #1
0
    def setUpTestData(cls):
        # Create a sport, a term belonging to that sport & 10 definitions for that term
        sport = SportFactory.create(name='Sport')
        cls.term = TermFactory.create(sport=sport, text='Term for sport')

        cls.user = UserFactory.create(username='******')
        DefinitionFactory.create_batch(10, term=cls.term, user=cls.user)
Example #2
0
    def test_num_downvotes(self):
        definition = DefinitionFactory.create(term=self.term, user=self.user)
        user2 = UserFactory.create()

        definition.downvote(user=self.user)
        definition.downvote(user=user2)

        self.assertEqual(definition.num_downvotes(), 2)
Example #3
0
 def setUpTestData(cls):
     u = UserFactory.create()
     su = UserFactory.create(is_staff=True)
     s = SportFactory.create()
     t = TermFactory.create(user=u, sport=s)
     SuggestedTermFactory.create(user=u, sport=s)
     CategoryFactory.create(sport=s)
     d = DefinitionFactory.create(user=u, term=t)
     VoteFactory.create(user=u, definition=d)
    def test_num_upvotes(self):
        definition = DefinitionFactory.create(term=self.term, user=self.user)
        user2 = UserFactory.create()
        user3 = UserFactory.create()

        definition.upvote(user=self.user)
        definition.upvote(user=user2)
        definition.upvote(user=user3)

        self.assertEqual(definition.num_upvotes, 3)
Example #5
0
    def test_net_votes(self):
        definition = DefinitionFactory.create(term=self.term, user=self.user)
        user2 = UserFactory.create()
        user3 = UserFactory.create()
        user4 = UserFactory.create()
        user5 = UserFactory.create()

        definition.upvote(user=self.user)
        definition.upvote(user=user2)
        definition.upvote(user=user3)

        definition.downvote(user=user4)
        definition.downvote(user=user5)

        self.assertEqual(definition.num_net_votes(), 1)
        self.assertEqual(definition.num_upvotes() - definition.num_downvotes(),
                         definition.net_votes)
Example #6
0
    def test_num_approved_definitions(self):
        term = TermFactory.create(
            text='term to test number of approved definitions',
            sport=self.sport,
            user=self.user)

        # these created definitions are approved by default
        DefinitionFactory.create(term=term, user=self.user)
        DefinitionFactory.create(term=term, user=self.user)

        # this definition has to be disapproved
        DefinitionFactory.create(term=term, user=self.user, approvedFl=False)

        self.assertEqual(term.num_approved_definitions(), 2)
Example #7
0
 def setUpTestData(cls):
     cls.user = UserFactory.create()
     cls.sport = SportFactory.create()
     cls.term = TermFactory.create()
     cls.definition = DefinitionFactory.create()
     cls.vote = VoteFactory.create()