Ejemplo n.º 1
0
    def test_delete_vote_comments(self):
        c, t = self.data_setup()

        report = reports.commentreport.get_commented_votes(c.key)
        subs_key = submissionrecord.make_submission(t.key, c.key, "track",
                                                    "format")
        vote1 = voterecord.cast_new_vote(subs_key, "New reviewer", 1,
                                         "Comment", 1)
        vote2 = voterecord.cast_new_vote(subs_key, "Another reviewer", 1,
                                         "Good", 1)
        vote3 = voterecord.cast_new_vote(subs_key, "3rd reviewer", 1, "Bad",
                                         -1)
        vote4 = voterecord.cast_new_vote(subs_key, "4th", 1, "", 3)

        self.assertEquals("Comment", vote1.comment)
        self.assertEquals("Good", vote2.comment)
        self.assertEquals("Bad", vote3.comment)
        self.assertEquals("", vote4.comment)

        reports.commentreport.delete_vote_comments(
            [vote1.key, vote2.key, vote3.key, vote4.key])
        self.assertEquals("", vote1.comment)
        self.assertEquals("", vote2.comment)
        self.assertEquals("", vote3.comment)
        self.assertEquals("", vote4.comment)

        # check they are in the db correctly
        # Todo: this test always works... even when put removed... need to fix
        votes = voterecord.find_existing_votes(subs_key, 1)
        for v in votes:
            self.assertEquals("", v.comment)
Ejemplo n.º 2
0
def retrieve_all_reviews(submission):
    reviews = []
    for r in range(1, submission.last_review_round + 1):
        round_reviews = voterecord.find_existing_votes(submission.key, r)
        if not (round_reviews is None):
            reviews = reviews + round_reviews

    return reviews
Ejemplo n.º 3
0
    def test_mutiple_submissions_without_duplicate_votes(self):
        VotingRound = 1
        submission_keys = self.common_data_setup()

        existing_vote = voterecord.find_existing_vote_by_reviewer(
            submission_keys[0], "Allan", VotingRound)
        self.assertTrue(existing_vote is None)

        voterecord.cast_new_vote(submission_keys[0], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[0], "Grisha", 2, "Two",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[0], "Anton", -1, "Minus 1",
                                 VotingRound)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[0], 1)), 3)

        existing_vote = voterecord.find_existing_vote_by_reviewer(
            submission_keys[1], "Allan", VotingRound)
        self.assertTrue(existing_vote is None)

        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Grisha", 2, "Two",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Anton", -1, "Minus 1",
                                 VotingRound)
        self.assertEqual(
            submission_keys[1].get().get_scores(VotingRound).total_score, 2)

        duplicates_list = dedupvotes.find_duplicate_votes(
            self.c.key, VotingRound)
        self.assertEquals(len(duplicates_list), 0)

        dedupvotes.remove_duplicates(duplicates_list)

        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[0],
                                               VotingRound)), 3)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[1],
                                               VotingRound)), 3)
        self.assertEqual(
            submission_keys[1].get().get_scores(VotingRound).total_score, 2)
Ejemplo n.º 4
0
def find_duplicate_votes(conf_key, round):
    duplicates = {}
    for sub in submissionrecord.retrieve_conference_submissions(conf_key):
        votes = voterecord.find_existing_votes(sub.key, round)
        for reviewer in extract_reviewers(votes):
            votes_cast = reviewer_votes(reviewer, votes)
            if len(votes_cast) > 1:
                duplicates[reviewer] = votes_cast

    return duplicates
Ejemplo n.º 5
0
    def test_find_existing_vote(self):
        c, t = self.data_setup()

        subs_key = submissionrecord.make_submission(t.key, c.key, "track",
                                                    "format")
        self.assertEquals(
            len(submission_queries.retrieve_conference_submissions(c.key)), 1)

        existing_vote = voterecord.find_existing_votes(subs_key, 1)
        self.assertTrue(existing_vote is None)

        voterecord.cast_new_vote(subs_key, "Reviewer", 2, "No comment", 1)
        reviews = voterecord.find_existing_votes(subs_key, 1)
        self.assertEquals(len(reviews), 1)
        self.assertEquals(reviews[0].reviewer, "Reviewer")

        voterecord.cast_new_vote(subs_key, "Another Reviewer", 2,
                                 "yes comment", 1)
        reviews = voterecord.find_existing_votes(subs_key, 1)
        self.assertEquals(len(reviews), 2)
        self.assertEquals(reviews[0].reviewer, "Reviewer")
        self.assertEquals(reviews[1].reviewer, "Another Reviewer")
Ejemplo n.º 6
0
    def test_delete_conference(self):
        conf1_key, sub1_key = self.mk_test_data("WorldConf 1000")
        conf2_key, sub2_key = self.mk_test_data("WorldConf 2000")

        self.assertEquals(
            1,
            len(submissionrecord.retrieve_conference_submissions(conf1_key)))
        self.assertEquals(
            1,
            len(submissionrecord.retrieve_conference_submissions(conf2_key)))
        self.assertEquals(1, len(voterecord.find_existing_votes(sub1_key, 1)))
        self.assertEquals(1, len(voterecord.find_existing_votes(sub2_key, 1)))
        self.assertEquals(1, len(cospeaker.get_cospeakers(sub1_key)))
        self.assertEquals(1, len(cospeaker.get_cospeakers(sub2_key)))
        self.assertEquals(2, confoptions.get_next_counter(conf1_key))
        self.assertEquals(2, confoptions.get_next_counter(conf2_key))
        self.assertEquals(6, len(ndb.Query(ancestor=conf1_key).fetch()))
        self.assertEquals(6, len(ndb.Query(ancestor=conf2_key).fetch()))

        confdb.delete_conference(conf2_key)
        self.assertEquals(None, conf2_key.get())

        self.assertEquals(
            1,
            len(submissionrecord.retrieve_conference_submissions(conf1_key)))
        self.assertEquals(
            0,
            len(submissionrecord.retrieve_conference_submissions(conf2_key)))
        self.assertEquals(1, len(voterecord.find_existing_votes(sub1_key, 1)))
        self.assertEquals(None, voterecord.find_existing_votes(sub2_key, 1))
        self.assertEquals(1, len(cospeaker.get_cospeakers(sub1_key)))
        self.assertEquals(0, len(cospeaker.get_cospeakers(sub2_key)))
        self.assertEquals(3, confoptions.get_next_counter(conf1_key))

        self.assertEquals(0, len(ndb.Query(ancestor=conf2_key).fetch()))
        self.assertEquals(None, conf2_key.get())
        self.assertEquals(None, confdb.get_conf_by_name("WorldConf 2000"))
Ejemplo n.º 7
0
    def test_dedup_leave_other_rounds(self):
        VotingRound = 1
        submission_keys = self.common_data_setup()

        existing_vote = voterecord.find_existing_vote_by_reviewer(
            submission_keys[0], "Allan", VotingRound)
        self.assertTrue(existing_vote is None)

        voterecord.cast_new_vote(submission_keys[0], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[0], "Grisha", 2, "Two",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[0], "Anton", -1, "Minus 1",
                                 VotingRound)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[0],
                                               VotingRound)), 3)

        existing_vote = voterecord.find_existing_vote_by_reviewer(
            submission_keys[1], "Allan", VotingRound)
        self.assertTrue(existing_vote is None)

        # Set up the bug
        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Grisha", 2, "Two",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Anton", -1, "Minus 1",
                                 VotingRound)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[1],
                                               VotingRound)), 5)

        # This is the bug
        # Because of extra vote the total is wrong
        self.assertEqual(
            submission_keys[1].get().get_scores(VotingRound).total_score, 4)

        # Add votes for another round, also with duplicates
        voterecord.cast_new_vote(submission_keys[0], "Harry", 1, "One",
                                 VotingRound + 1)
        voterecord.cast_new_vote(submission_keys[0], "Ron", 2, "Two",
                                 VotingRound + 1)
        voterecord.cast_new_vote(submission_keys[0], "Percy", -1, "Minus 1",
                                 VotingRound + 1)
        self.assertEquals(
            len(
                voterecord.find_existing_votes(submission_keys[0],
                                               VotingRound + 1)), 3)
        voterecord.cast_new_vote(submission_keys[1], "Harry", 1, "One",
                                 VotingRound + 1)
        voterecord.cast_new_vote(submission_keys[1], "Harry", 1, "One",
                                 VotingRound + 1)
        voterecord.cast_new_vote(submission_keys[1], "Harry", 1, "One",
                                 VotingRound + 1)
        voterecord.cast_new_vote(submission_keys[1], "Ron", 2, "Two",
                                 VotingRound + 1)
        voterecord.cast_new_vote(submission_keys[1], "Percy", -1, "Minus 1",
                                 VotingRound + 1)
        self.assertEquals(
            len(
                voterecord.find_existing_votes(submission_keys[1],
                                               VotingRound + 1)), 5)

        duplicates_list = dedupvotes.find_duplicate_votes(
            self.c.key, VotingRound)
        self.assertEquals(len(duplicates_list), 1)
        self.assertEquals(len(duplicates_list[duplicates_list.keys()[0]]), 3)
        self.assertEquals(len(duplicates_list["Allan"]), 3)

        dedupvotes.remove_duplicates(duplicates_list)

        # Check it was all done
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[0],
                                               VotingRound)), 3)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[1],
                                               VotingRound)), 3)

        # And the total score is now correct
        self.assertEqual(
            submission_keys[1].get().get_scores(VotingRound).total_score, 2)

        # Check second round wasn't touched
        self.assertEquals(
            len(
                voterecord.find_existing_votes(submission_keys[0],
                                               VotingRound + 1)), 3)
        self.assertEquals(
            len(
                voterecord.find_existing_votes(submission_keys[1],
                                               VotingRound + 1)), 5)

        # Fix it
        second_duplicates_list = dedupvotes.find_duplicate_votes(
            self.c.key, VotingRound + 1)
        dedupvotes.remove_duplicates(second_duplicates_list)

        self.assertEquals(
            len(
                voterecord.find_existing_votes(submission_keys[0],
                                               VotingRound + 1)), 3)
        self.assertEquals(
            len(
                voterecord.find_existing_votes(submission_keys[1],
                                               VotingRound + 1)), 3)
        self.assertEqual(
            submission_keys[0].get().get_scores(VotingRound + 1).total_score,
            2)
        self.assertEqual(
            submission_keys[1].get().get_scores(VotingRound + 1).total_score,
            2)
Ejemplo n.º 8
0
    def test_multiple_submissions_with_duplicate_votes(self):
        VotingRound = 1
        submission_keys = self.common_data_setup()

        existing_vote = voterecord.find_existing_vote_by_reviewer(
            submission_keys[0], "Allan", VotingRound)
        self.assertTrue(existing_vote is None)

        voterecord.cast_new_vote(submission_keys[0], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[0], "Grisha", 2, "Two",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[0], "Anton", -1, "Minus 1",
                                 VotingRound)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[0], 1)), 3)

        existing_vote = voterecord.find_existing_vote_by_reviewer(
            submission_keys[1], "Allan", VotingRound)
        self.assertTrue(existing_vote is None)

        # Set up the bug
        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Grisha", 2, "Two",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Anton", -1, "Minus 1",
                                 VotingRound)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[1],
                                               VotingRound)), 5)

        # This is the bug
        # Because of extra vote the total is wrong
        self.assertEqual(
            submission_keys[1].get().get_scores(VotingRound).total_score, 4)

        # Another submission with duplicae votes
        t3 = talk.Talk()
        t3.title = "Talk3 - Another submission with duplicates"
        t3.put()

        subs_key3 = submissionrecord.make_submission(t3.key, self.c.key,
                                                     "track", "format")
        submission_keys.append(subs_key3)
        self.assertEquals(
            len(submissionrecord.retrieve_conference_submissions(self.c.key)),
            3)
        voterecord.cast_new_vote(submission_keys[2], "Harry", 2, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[2], "Ron", 2, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[2], "Draco", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[2], "Draco", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[2], "Draco", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[2], "Percy", 3, "Three",
                                 VotingRound)
        # check the bug is in place
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[2],
                                               VotingRound)), 6)
        self.assertEqual(
            submission_keys[2].get().get_scores(VotingRound).total_score, 10)

        duplicates_list = dedupvotes.find_duplicate_votes(
            self.c.key, VotingRound)
        self.assertEquals(len(duplicates_list), 2)

        dedupvotes.remove_duplicates(duplicates_list)

        # Check it was all done
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[0],
                                               VotingRound)), 3)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[1],
                                               VotingRound)), 3)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[2],
                                               VotingRound)), 4)

        # And the total score is now correct
        self.assertEqual(
            submission_keys[0].get().get_scores(VotingRound).total_score, 2)
        self.assertEqual(
            submission_keys[1].get().get_scores(VotingRound).total_score, 2)
        self.assertEqual(
            submission_keys[2].get().get_scores(VotingRound).total_score, 8)
Ejemplo n.º 9
0
    def test_find_and_remove_duplicate_votes(self):
        VotingRound = 1
        submission_keys = self.common_data_setup()

        existing_vote = voterecord.find_existing_vote_by_reviewer(
            submission_keys[0], "Allan", VotingRound)
        self.assertTrue(existing_vote is None)

        voterecord.cast_new_vote(submission_keys[0], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[0], "Grisha", 2, "Two",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[0], "Anton", -1, "Minus 1",
                                 VotingRound)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[0],
                                               VotingRound)), 3)

        existing_vote = voterecord.find_existing_vote_by_reviewer(
            submission_keys[1], "Allan", VotingRound)
        self.assertTrue(existing_vote is None)

        # Set up the bug
        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Allan", 1, "One",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Grisha", 2, "Two",
                                 VotingRound)
        voterecord.cast_new_vote(submission_keys[1], "Anton", -1, "Minus 1",
                                 VotingRound)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[1],
                                               VotingRound)), 5)

        # This is the bug
        # Because of extra vote the total is wrong
        self.assertEqual(
            submission_keys[1].get().get_scores(VotingRound).total_score, 4)

        duplicates_list = dedupvotes.find_duplicate_votes(
            self.c.key, VotingRound)
        self.assertEquals(len(duplicates_list), 1)
        self.assertEquals(len(duplicates_list[duplicates_list.keys()[0]]), 3)
        self.assertEquals(len(duplicates_list["Allan"]), 3)

        dedupvotes.remove_duplicates(duplicates_list)

        # Check it was all done
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[0],
                                               VotingRound)), 3)
        self.assertEquals(
            len(voterecord.find_existing_votes(submission_keys[1],
                                               VotingRound)), 3)

        # And the total score is now correct
        self.assertEqual(
            submission_keys[1].get().get_scores(VotingRound).total_score, 2)