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 setUp(self):
        SEED = 'discussion'
        self.random_generator = random.Random(SEED)
        self.base_url = '/api/'
        self.user = create_random_authenticated_user('discussion_permissions')
        self.paper = create_paper(uploaded_by=self.user)
        self.thread = create_thread(paper=self.paper, created_by=self.user)
        self.comment = create_comment(thread=self.thread, created_by=self.user)
        self.reply = create_reply(parent=self.comment, created_by=self.user)
        self.trouble_maker = create_random_authenticated_user('trouble_maker')
        self.author = create_random_authenticated_user('author')
        self.moderator = create_random_authenticated_user('moderator')

        self.add_paper_author(Author.objects.get(user=self.author))
        self.add_paper_moderator(self.moderator)
    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)
 def test_comment_users_to_notify_includes_thread_creator(self):
     user = create_random_default_user('Eamy')
     thread = create_thread(created_by=user)
     comment = create_comment(thread=thread)
     self.assertTrue(user in comment.users_to_notify)
 def test_thread_users_to_notify_exlcudes_non_author_creator(self):
     user = create_random_default_user('Non-author')
     thread = create_thread(paper=self.paper, created_by=user)
     self.assertFalse(user in thread.users_to_notify)
 def test_creating_thread_notifies_post_creator(self):
     creator = create_random_default_user('Creator')
     thread_creator = create_random_default_user('ThreadCreator')
     post = create_post(created_by=creator)
     thread = create_thread(post=post, created_by=thread_creator)
     self.assertTrue(creator in thread.users_to_notify)
 def test_thread_creator_not_receive_notification_on_own_contribution(self):
     submitter = create_random_default_user('Submitter')
     commenter = create_random_default_user('Commenter')
     paper = create_paper(uploaded_by=submitter)
     thread = create_thread(paper=paper, created_by=commenter)
     self.assertFalse(commenter in thread.users_to_notify)
 def test_creating_comment_notifies_paper_submitter(self):
     submitter = create_random_default_user('Submitter')
     paper = create_paper(uploaded_by=submitter)
     thread = create_thread(paper=paper)
     comment = create_comment(thread=thread)
     self.assertTrue(submitter in comment.users_to_notify)
 def test_creating_thread_notifies_paper_submitter(self):
     submitter = create_random_default_user('Submitter')
     commenter = create_random_default_user('Commenter')
     paper = create_paper(uploaded_by=submitter)
     thread = create_thread(paper=paper, created_by=commenter)
     self.assertTrue(submitter in thread.users_to_notify)
 def setUp(self):
     self.paper = create_paper()
     self.thread = create_thread(paper=self.paper)
     self.comment = create_comment(thread=self.thread)
     self.reply = create_reply(parent=self.comment)
 def test_can_NOT_endorse_thread_if_not_author_or_moderator(self):
     thread = create_thread(title='N', paper=self.paper)
     response = self.get_thread_endorsement_post_response(self.user, thread)
     self.assertEqual(response.status_code, 403)
 def test_moderator_can_endorse_thread(self):
     thread = create_thread(title='M', paper=self.paper)
     response = self.get_thread_endorsement_post_response(
         self.moderator, thread)
     self.assertContains(response, thread.id, status_code=201)