def test_get_reviewer(self): self.assertIsNone( reviewer.get_reviewer(self.conference.key, "*****@*****.**")) reviewer.make_new_reviewer(self.conference.key, "*****@*****.**") r = reviewer.get_reviewer(self.conference.key, "*****@*****.**") self.assertIsNotNone(r) self.assertEquals("*****@*****.**", r.email)
def test_current_review_assisgments(self): sub_key1, sub_key2, sub_key3 = self.setup_test_data() reviewer1 = reviewer.make_new_reviewer(self.conference.key, "rimmer@email") self.assertItemsEqual([], reviewer1.retrieve_review_assignments( "track", review_round=1)) self.assertItemsEqual( [], reviewer1.retrieve_review_assignments_for_round(review_round=1)) reviewer2 = reviewer.make_new_reviewer(self.conference.key, "cat@email") self.assertItemsEqual([], reviewer1.retrieve_review_assignments( "track", review_round=1)) reviewer1.assign_submission("track", [sub_key3], review_round=1) self.assertItemsEqual([sub_key3], reviewer1.retrieve_review_assignments( "track", review_round=1)) self.assertItemsEqual( [sub_key3], reviewer1.retrieve_review_assignments_for_round(review_round=1)) reviewer1.assign_submission("track", [sub_key2], review_round=1) self.assertItemsEqual([sub_key2, sub_key3], reviewer1.retrieve_review_assignments( "track", review_round=1)) self.assertItemsEqual( [sub_key2, sub_key3], reviewer1.retrieve_review_assignments_for_round(review_round=1)) reviewer2.assign_submission("track", [sub_key1, sub_key2], review_round=1) self.assertItemsEqual([sub_key2, sub_key1], reviewer2.retrieve_review_assignments( "track", review_round=1)) t4 = talk.Talk(parent=None) t4.title = "Nobody on another track" t4.put() sub_key4 = submissionrecord.make_submission(t4.key, self.conference.key, "another_track", "format") reviewer1.assign_submission("another_track", [sub_key4], review_round=1) self.assertItemsEqual([sub_key2, sub_key3], reviewer1.retrieve_review_assignments( "track", review_round=1)) self.assertItemsEqual([sub_key4], reviewer1.retrieve_review_assignments( "another_track", review_round=1)) self.assertItemsEqual( [sub_key2, sub_key3, sub_key4], reviewer1.retrieve_review_assignments_for_round(review_round=1))
def test_own_submissions(self): sub_key1, sub_key2, sub_key3 = self.setup_test_data() reviewer1 = reviewer.make_new_reviewer(self.conference.key, "rimmer@email") self.assertItemsEqual([sub_key1, sub_key2], reviewer1.own_submissions()) reviewer2 = reviewer.make_new_reviewer(self.conference.key, "cat@email") self.assertItemsEqual([sub_key3], reviewer2.own_submissions())
def test_count_submission_reviewers(self): sub_key1, sub_key2, sub_key3 = self.setup_test_data() reviewer1 = reviewer.make_new_reviewer(self.conference.key, "rimmer@email") reviewer1.assign_submission("track", [sub_key1, sub_key2], review_round=1) reviewer2 = reviewer.make_new_reviewer(self.conference.key, "cat@email") reviewer2.assign_submission("track", [sub_key1], review_round=1) subs_count = reviewer.count_submission_reviewers( [sub_key1, sub_key2, sub_key3], review_round=1) self.assertEqual(sub_key1, subs_count[0][0]) self.assertEqual(2, subs_count[0][1]) self.assertEqual(sub_key2, subs_count[1][0]) self.assertEqual(1, subs_count[1][1]) self.assertEqual(sub_key3, subs_count[2][0]) self.assertEqual(0, subs_count[2][1])
def test_retrieve_reviewers(self): sub_key1, sub_key2, sub_key3 = self.setup_test_data() self.assertEquals( 0, len(reviewer.get_reviewers(sub_key1, review_round=1))) self.assertEquals( 0, len(reviewer.get_reviewers(sub_key1, review_round=2))) # new reviewer with no reviews r = reviewer.make_new_reviewer(self.conference.key, "*****@*****.**") # assign a submission r.assign_submission("track", [sub_key1], review_round=1) reviewers = reviewer.get_reviewers(sub_key1, review_round=1) self.assertEquals(1, len(reviewers)) self.assertEquals([r.key], reviewers) r2 = reviewer.make_new_reviewer(self.conference.key, "*****@*****.**") r2.assign_submission("track", [sub_key1], review_round=1) reviewers = reviewer.get_reviewers(sub_key1, review_round=1) self.assertEquals(2, len(reviewers)) self.assertEquals([r.key, r2.key], reviewers) self.assertEquals( 0, len(reviewer.get_reviewers(sub_key1, review_round=2))) r3 = reviewer.make_new_reviewer(self.conference.key, "*****@*****.**") r3.assign_submission("track", [sub_key1], review_round=1) reviewers = reviewer.get_reviewers(sub_key1, review_round=1) self.assertEquals(3, len(reviewers)) self.assertEquals([r.key, r2.key, r3.key], reviewers) self.assertEquals( 0, len(reviewer.get_reviewers(sub_key1, review_round=2))) self.assertEquals( 0, len(reviewer.get_reviewers(sub_key2, review_round=1))) self.assertEquals( 0, len(reviewer.get_reviewers(sub_key3, review_round=1)))
def get(self): crrt_conf = self.get_crrt_conference_key().get() rights = crrt_conf.user_rights() review_tracks = rights.tracks_to_review(self.get_crrt_user().email()) if self.request.params.has_key("track"): crrt_track = self.request.get("track") else: if len(review_tracks) > 0: # no key so default to first track in list crrt_track = review_tracks[0] else: # no tracks or no review rights crrt_track = "None" # review_tracks[0] sorrypage.redirect_sorry(self, "NoTracksAssigned") return named_reviewer = reviewer.get_reviewer(crrt_conf.key, self.get_crrt_user().email()) if named_reviewer is None: named_reviewer = reviewer.make_new_reviewer( crrt_conf.key, self.get_crrt_user().email()) review_round = int(self.request.get("round")) records = named_reviewer.retrieve_review_assignments( crrt_track, review_round) newscoringconfig = confreviewconfig.get_conference_review_factory(crrt_conf.key). \ get_round_config(int(self.request.get("round"))) if newscoringconfig.is_speaker_named(): show_name = True else: show_name = False template_values = { "conference_submissions": map(lambda s: s.get(), records), "count_submissions": len(records), "selected_conf": crrt_conf.name, "useremail": self.get_crrt_user().email(), "review_tracks": review_tracks, "track_dictionary": crrt_conf.track_options(), "selected_track": crrt_track, "durations": crrt_conf.duration_options(), "review_round": review_round, "show_name": show_name } self.write_page('subreview_lib/newscoringlistpage.html', template_values)
def test_reviewer_complete_description(self): self.assertEquals( "", votingrecordspage.reviewer_complete_description( self.conference.key, "nosuch@revewer", 1)) reviewer1 = reviewer.make_new_reviewer(self.conference.key, "rimmer@email") self.assertEquals( "", votingrecordspage.reviewer_complete_description( self.conference.key, "rimmer@email", 1)) self.assertEquals( "", votingrecordspage.reviewer_complete_description( self.conference.key, "rimmer@email", 2)) reviewer1.set_complete(True, review_round=1) self.assertEquals( "Complete", votingrecordspage.reviewer_complete_description( self.conference.key, "rimmer@email", 1)) self.assertEquals( "", votingrecordspage.reviewer_complete_description( self.conference.key, "rimmer@email", 2)) reviewer1.set_complete(True, review_round=2) self.assertEquals( "Complete", votingrecordspage.reviewer_complete_description( self.conference.key, "rimmer@email", 1)) self.assertEquals( "Complete", votingrecordspage.reviewer_complete_description( self.conference.key, "rimmer@email", 2)) reviewer1.set_complete(False, 1) self.assertEquals( "", votingrecordspage.reviewer_complete_description( self.conference.key, "rimmer@email", 1)) self.assertEquals( "Complete", votingrecordspage.reviewer_complete_description( self.conference.key, "rimmer@email", 2))
def test_count_assignments(self): sub_key1, sub_key2, sub_key3 = self.setup_test_data() r = reviewer.make_new_reviewer(self.conference.key, "*****@*****.**") self.assertEquals(0, r.count_assignments(1)) self.assertEquals(0, r.count_assignments(2)) r.assign_submission("track", [sub_key1, sub_key2], review_round=1) self.assertEquals(2, r.count_assignments(1)) r.assign_submission("track", [sub_key3], review_round=2) self.assertEquals(2, r.count_assignments(review_round=1)) self.assertEquals(1, r.count_assignments(review_round=2)) sub_key4, sub_key5, sub_key6 = self.setup_test_data() r.assign_submission("trackX", [sub_key4, sub_key5, sub_key6], review_round=1) self.assertEquals(1, r.count_assignments(review_round=2)) self.assertEquals(5, r.count_assignments(review_round=1))
def test_assign_limited_to_round(self): round1_key1, round1_sub_key2, round1_key3 = self.setup_test_data() reviewer1 = reviewer.make_new_reviewer(self.conference.key, "lister@email") reviewer1.assign_more_reviews("track", 99, 1) self.assertItemsEqual([round1_key1, round1_sub_key2, round1_key3], reviewer1.retrieve_review_assignments( "track", 1)) round2_key4, round2_key5, round1_key6 = self.setup_test_data() self.set_round2(round2_key4) self.set_round2(round2_key5) reviewer1.assign_more_reviews("track", 99, 2) self.assertItemsEqual([round2_key4, round2_key5], reviewer1.retrieve_review_assignments( "track", 2)) self.assertItemsEqual([round1_key1, round1_sub_key2, round1_key3], reviewer1.retrieve_review_assignments( "track", 1))
def test_remove_review_assisgments(self): sub_key1, sub_key2, sub_key3 = self.setup_test_data() reviewer1 = reviewer.make_new_reviewer(self.conference.key, "rimmer@email") reviewer1.assign_submission("track", [sub_key1, sub_key3, sub_key2], review_round=1) self.assertItemsEqual([sub_key3, sub_key2, sub_key1], reviewer1.retrieve_review_assignments( "track", review_round=1)) reviewer1.remove_assignment("track", review_round=1, target=sub_key1) self.assertItemsEqual([sub_key2, sub_key3], reviewer1.retrieve_review_assignments( "track", review_round=1)) # Need to requery db to ensure update was made # Original version of remove_assignment missed a put() after operation refresh_reviewer = reviewer.get_reviewer(self.conference.key, "rimmer@email") self.assertItemsEqual([sub_key2, sub_key3], refresh_reviewer.retrieve_review_assignments( "track", review_round=1))
def test_delete_conference(self): c = conference.Conference() c.name = "TestConf" c.put() ur = userrights.UserRights(c.key) ur.add_track_reviewer("harry", "technology track") self.assertEquals( 1, self.count_db_entries(userrights.RightsRecord, c.key)) track1 = confoptions.make_conference_track(c.key, "New Track") track2 = confoptions.make_conference_track(c.key, "Another track") self.assertEquals( 2, self.count_db_entries(confoptions.TrackOption, c.key)) duration1 = confoptions.make_conference_option( confoptions.DurationOption, c.key, "30 minutes") self.assertEquals( 1, self.count_db_entries(confoptions.DurationOption, c.key)) confoptions.make_conference_option(confoptions.TalkFormatOption, c.key, "Lecture") self.assertEquals( 1, self.count_db_entries(confoptions.TalkFormatOption, c.key)) confoptions.make_conference_option(confoptions.ExpenseOptions, c.key, "Local") self.assertEquals( 1, self.count_db_entries(confoptions.ExpenseOptions, c.key)) review_config = confreviewconfig.get_conference_review_factory(c.key) self.assertIsNotNone(review_config) self.assertEquals( 1, self.count_db_entries(confreviewconfig.ConferenceReviewFactory, c.key)) self.assertEquals( 0, self.count_db_entries(confreviewconfig.ClassicReview, c.key)) self.assertEquals( 1, self.count_db_entries(confreviewconfig.NewScoringReview, c.key)) self.assertEquals( 1, self.count_db_entries(confreviewconfig.RankReview, c.key)) s = speaker.make_new_speaker("mail@email") s.name = "Arnold Rimmer" s.put() t = talk.Talk(parent=s.key) t.title = "A testing talk" t.put() sub_key = submissionrecord.make_submission(t.key, c.key, "track", "format") self.assertEquals( 1, self.count_db_entries(submissionrecord.SubmissionRecord, c.key)) vote = voterecord.cast_new_vote(sub_key, "Reviewer1", 2, "No comment", 1) self.assertEquals(1, self.count_db_entries(voterecord.VoteRecord, c.key)) rev = reviewer.make_new_reviewer(c.key, "rimmer@email") self.assertEquals(1, self.count_db_entries(reviewer.Reviewer, c.key)) rev.assign_submission("track", [sub_key], review_round=1) self.assertEquals( 1, self.count_db_entries(reviewer.ReviewAssignment, c.key)) confdelete.cascade_delete_conference(c.key) self.assertEquals( 0, self.count_db_entries(userrights.RightsRecord, c.key)) self.assertEquals( 0, self.count_db_entries(submissionrecord.SubmissionRecord, c.key)) self.assertEquals(0, self.count_db_entries(voterecord.VoteRecord, c.key)) self.assertEquals( 0, self.count_db_entries(confoptions.TrackOption, c.key)) self.assertEquals( 0, self.count_db_entries(confoptions.DurationOption, c.key)) self.assertEquals( 0, self.count_db_entries(confoptions.TalkFormatOption, c.key)) self.assertEquals( 0, self.count_db_entries(confoptions.ExpenseOptions, c.key)) self.assertEquals( 0, self.count_db_entries(confoptions.AcknowledgementEmailCCAddresses, c.key)) self.assertEquals( 0, self.count_db_entries(confoptions.AcknowledgementEmailBCCAddresses, c.key)) self.assertEquals( 0, self.count_db_entries(confoptions.AcceptEmailCCAddress, c.key)) self.assertEquals( 0, self.count_db_entries(confreviewconfig.ConferenceReviewFactory, c.key)) self.assertEquals( 0, self.count_db_entries(confreviewconfig.ClassicReview, c.key)) self.assertEquals( 0, self.count_db_entries(confreviewconfig.NewScoringReview, c.key)) self.assertEquals( 0, self.count_db_entries(confreviewconfig.RankReview, c.key)) self.assertEquals( 0, self.count_db_entries(dedupvotes.DuplicateVoteReport, c.key)) self.assertEquals( 0, self.count_db_entries(reviewer.ReviewAssignment, c.key)) self.assertEquals(0, self.count_db_entries(reviewer.Reviewer, c.key))
def test_assign_more_reviews(self): # basic test sub_key1, sub_key2, sub_key3 = self.setup_test_data() reviewer1 = reviewer.make_new_reviewer(self.conference.key, "lister@email") reviewer1.assign_more_reviews("track", 2, 1) self.assertEqual( 2, len(reviewer1.retrieve_review_assignments("track", review_round=1))) reviewer2 = reviewer.make_new_reviewer(self.conference.key, "cat@email") self.assertEqual( 2, len(reviewer1.retrieve_review_assignments("track", review_round=1))) reviewer2.assign_more_reviews("track", 2, 1) self.assertEqual( 2, len(reviewer2.retrieve_review_assignments("track", review_round=1))) # three possible success scenarios - don't care which was chosen # on suubmission should be assigned to both reviewers # other submissions should both be assigned to one reviewer # less assigned submissions shoul be assigned first # then semi-random assignment up to totoal if (reviewer.count_submission_assignments(self.conference.key, sub_key1, 1) == 2): print "*** First assignment case" self.assertEqual( 1, reviewer.count_submission_assignments(self.conference.key, sub_key3, 1)) self.assertEqual( 1, reviewer.count_submission_assignments(self.conference.key, sub_key2, 1)) elif (reviewer.count_submission_assignments(self.conference.key, sub_key2, 1) == 2): print "*** Second assignment case" self.assertEqual( 1, reviewer.count_submission_assignments(self.conference.key, sub_key1, 1)) self.assertEqual( 1, reviewer.count_submission_assignments(self.conference.key, sub_key3, 1)) elif (reviewer.count_submission_assignments(self.conference.key, sub_key3, 1) == 2): print "*** Third assignment case" self.assertEqual( 1, reviewer.count_submission_assignments(self.conference.key, sub_key1, 1)) self.assertEqual( 1, reviewer.count_submission_assignments(self.conference.key, sub_key2, 1)) else: self.assertFalse(True, "Unexpected assignment pattern") reviewer3 = reviewer.make_new_reviewer(self.conference.key, "kyton@email") reviewer3.assign_more_reviews("track", 2, 1) self.assertEqual( 2, reviewer.count_submission_assignments(self.conference.key, sub_key1, 1)) self.assertEqual( 2, reviewer.count_submission_assignments(self.conference.key, sub_key2, 1)) self.assertEqual( 2, reviewer.count_submission_assignments(self.conference.key, sub_key3, 1)) # check no repeated assignment reviewer1.assign_more_reviews("track", 2, 1) self.assertEqual( 3, len(reviewer1.retrieve_review_assignments("track", review_round=1))) reviewer1.assign_more_reviews("track", 2, 1) self.assertEqual( 3, len(reviewer1.retrieve_review_assignments("track", review_round=1))) # check no self-assignment rogue = "holy@email" s = speaker.make_new_speaker(rogue) s.name = "Holy" s.put() t4 = talk.Talk(parent=s.key) t4.title = "Lets see if the new speaker can review themselves" t4.put() sub_key4 = submissionrecord.make_submission(t4.key, self.conference.key, "track", "format") reviewer4 = reviewer.make_new_reviewer(self.conference.key, rogue) reviewer4.assign_more_reviews("track", 99, 1) self.assertItemsEqual([sub_key1, sub_key2, sub_key3], reviewer4.retrieve_review_assignments( "track", review_round=1)) self.assertEqual( 0, reviewer.count_submission_assignments(self.conference.key, sub_key4, 1))