def test_thread_upvoted_increases_rep_by_5(self):
        recipient = create_random_default_user('Percy')
        thread = create_thread(created_by=recipient)
        upvote_discussion(thread, self.user)

        recipient.refresh_from_db()
        self.assertEqual(recipient.reputation,
                         self.start_rep + self.new_user_create_rep + 5)
    def test_reply_upvoted_increases_rep_by_1(self):
        recipient = create_random_default_user('George')
        reply = create_reply(created_by=recipient)
        upvote_discussion(reply, self.user)

        earned_rep = distributions.ReplyUpvoted.amount

        recipient.refresh_from_db()
        self.assertEqual(
            recipient.reputation,
            self.start_rep + self.new_user_create_rep + earned_rep)
    def test_comment_by_paper_non_orcid_author_upvoted_increases_rep_1(self):
        recipient = create_random_default_user('Winky the Author')

        paper = create_paper()
        paper.authors.add(recipient.author_profile)

        thread = create_thread(paper=paper)
        comment = create_comment(thread=thread, created_by=recipient)

        upvote_discussion(comment, self.user)

        recipient.refresh_from_db()
        self.assertEqual(recipient.reputation,
                         self.start_rep + self.new_user_create_rep + 1)
    def test_multiple_reputation_distributions(self):
        thread = create_thread(created_by=self.recipient)
        current_rep = self.start_rep + self.new_user_create_rep

        self.recipient.refresh_from_db()
        self.assertEqual(self.recipient.reputation, current_rep)

        comment = create_comment(thread=thread, created_by=self.recipient)
        comment_vote = upvote_discussion(comment, self.user)
        current_rep = current_rep + 1 + self.new_user_create_rep

        self.recipient.refresh_from_db()
        self.assertEqual(self.recipient.reputation, current_rep)

        update_to_downvote(comment_vote)
        current_rep = current_rep - 1

        self.recipient.refresh_from_db()
        self.assertEqual(self.recipient.reputation, current_rep)

        reply = create_reply(parent=comment, created_by=self.recipient)
        reply_vote = downvote_discussion(reply, self.user)
        current_rep = current_rep - 1 + self.new_user_create_rep

        self.recipient.refresh_from_db()
        self.assertEqual(self.recipient.reputation, current_rep)

        update_to_upvote(reply_vote)
        current_rep += 1

        self.recipient.refresh_from_db()
        self.assertEqual(self.recipient.reputation, current_rep)
    def test_reply_upvoted_increases_rep_1_created_by_non_orcid_author(self):
        recipient = create_random_default_user('George the Author')

        paper = create_paper()
        paper.authors.add(recipient.author_profile)

        thread = create_thread(paper=paper)
        comment = create_comment(thread=thread)
        reply = create_reply(parent=comment, created_by=recipient)

        upvote_discussion(reply, self.user)

        earned_rep = (distributions.ReplyUpvoted.amount)

        recipient.refresh_from_db()
        self.assertEqual(recipient.reputation, self.start_rep + earned_rep)
    def test_comment_by_paper_orcid_author_upvoted_increases_rep_5(self):
        recipient = create_random_default_user('Winky the ORCID Author')
        social = create_social_account(OrcidProvider.id, recipient)
        recipient.author_profile.orcid_id = social.uid
        recipient.author_profile.save()

        paper = create_paper()
        paper.authors.add(recipient.author_profile)

        thread = create_thread(paper=paper)
        comment = create_comment(thread=thread, created_by=recipient)

        upvote_discussion(comment, self.user)

        recipient.refresh_from_db()
        self.assertEqual(recipient.reputation,
                         self.start_rep + self.new_user_create_rep + 5)
    def test_reply_upvoted_increases_rep_5_created_by_paper_orcid_author(self):
        recipient = create_random_default_user('George the Author')
        social = create_social_account(OrcidProvider.id, recipient)
        recipient.author_profile.orcid_id = social.uid
        recipient.author_profile.save()

        paper = create_paper()
        paper.authors.add(recipient.author_profile)

        thread = create_thread(paper=paper)
        comment = create_comment(thread=thread)
        reply = create_reply(parent=comment, created_by=recipient)

        upvote_discussion(reply, self.user)

        earned_rep = 0

        recipient.refresh_from_db()
        self.assertEqual(recipient.reputation, self.start_rep + earned_rep)
Ejemplo n.º 8
0
 def test_can_delete_upvote(self):
     comment_vote = upvote_discussion(self.comment, self.user)
     response = self.get_comment_vote_delete_response(self.user)
     self.assertContains(response, comment_vote.id, status_code=200)