def test_retrieve_conferences_in_review(self): self.assertEquals([], confdb.test_retrieve_conferences_not_finished()) conf_open = conference.Conference() conf_open.name = "WorldConf 2016" conf_open.open_for_submissions() conf_open.put() conf_closed = conference.Conference() conf_closed.name = "WorldConf 2017" conf_closed.close_submissions() conf_closed.put() conf_r1_review = conference.Conference() conf_r1_review.name = "WorldConf 2018" conf_r1_review.start_round1_reviews() conf_r1_review.put() conf_r2_review = conference.Conference() conf_r2_review.name = "WorldConf 2019" conf_r2_review.start_round2_reviews() conf_r2_review.put() conf_finished = conference.Conference() conf_finished.name = "WorldConf 2020" conf_finished.finish_reviews() conf_finished.put() expected_results = [conf_r1_review, conf_r2_review] expected_results.sort() actual_results = confdb.test_retrieve_conferences_not_finished() actual_results.sort() self.assertEquals(expected_results, actual_results)
def test_count_conferences(self): self.assertEquals(confdb.count_conferences(), 0) new_conf = conference.Conference() new_conf.name = "WorldConf 2016" new_conf.put() self.assertEquals(confdb.count_conferences(), 1) new_conf2 = conference.Conference() new_conf2.name = "WorldConf 2017" new_conf2.put() self.assertEquals(confdb.count_conferences(), 2)
def test_dummy_conference(self): new_conf = conference.Conference() new_conf.name = "WorldConf 2016" new_conf.put() self.assertFalse(new_conf.is_dummy_conf()) self.assertIsInstance(new_conf.user_rights(), userrights.UserRights) self.assertNotIsInstance(new_conf.user_rights(), openrights.OpenRights) dummy_conf = conference.Conference() dummy_conf.name = "World Dummy Conf 2016" dummy_conf.put() self.assertFalse(dummy_conf.is_dummy_conf())
def test_can_close_conference(self): c = conference.Conference() c.name = "TestConf" c.put() # No submissions so no outstanding decisions self.assertTrue(confstate.can_close_conference(c.key, 1)) t1 = talk.Talk() t1.title = "Talk T1" t1.put() sub_key1 = submissionrecord.make_submission(t1.key, c.key, "track", "format") # can't close while submission is undecided self.assertFalse(confstate.can_close_conference(c.key, 1)) sub = sub_key1.get() sub.set_review_decision(1, "Accept") sub.put() self.assertTrue(confstate.can_close_conference(c.key, 1)) t2 = talk.Talk() t2.title = "Talk T2" t2.put() sub_key2 = submissionrecord.make_submission(t2.key, c.key, "track", "format") self.assertFalse(confstate.can_close_conference(c.key, 1))
def test_has_permission(self): # most permission are live # except for creator which follows same rules as normal c = conference.Conference() c.name = "Test Dummy Conf" c.put() user = "******" self.assertTrue(c.user_rights() is not None) self.assertFalse(c.user_rights().has_permission( user, "ChangeConferenceState")) self.assertFalse(c.user_rights().has_permission(user, "NoneSuch")) c.user_rights().add_permission(user, "ChangeConferenceState") c.user_rights().add_permission(user, "NoneSuch") self.assertTrue(c.user_rights() is not None) self.assertTrue(c.user_rights().has_permission( user, "ChangeConferenceState")) self.assertTrue(c.user_rights().has_permission(user, "NoneSuch")) self.assertFalse(c.user_rights().has_permission( user, userrightsnames.CONF_CREATOR)) c.user_rights().add_permission(user, userrightsnames.CONF_CREATOR) self.assertTrue(c.user_rights().has_permission( user, userrightsnames.CONF_CREATOR))
def test_export_submissions_list(self): c = conference.Conference() c.name = "TestConf" c.put() track1 = confoptions.make_conference_track(c.key, "track") track2 = confoptions.make_conference_track(c.key, "another track") format1 = confoptions.make_conference_option(confoptions.TalkFormatOption, c.key, "lecture") duration1 = confoptions.make_conference_option(confoptions.DurationOption, c.key, "10mins") expenses1 = confoptions.make_conference_option(confoptions.ExpenseOptions, c.key, "Money") s = speaker.make_new_speaker("*****@*****.**") s.put() t = talk.Talk(parent=s.key) t.title = "A testing talk" t.put() sub_key = submissionrecord.make_submission_plus(t.key, c.key, track1.shortname(), format1.shortname(), duration1.shortname(), expenses1.shortname()) s2 = speaker.make_new_speaker("*****@*****.**") s2.put() t2 = talk.Talk(parent=s2.key) t2.title = "Knowing Rimmer" t2.put() sub_key2 = submissionrecord.make_submission_plus(t2.key, c.key, track2.shortname(), format1.shortname(), duration1.shortname(), expenses1.shortname()) output = MockOutStream() exportcsv.write_sub_list(output, [sub_key, sub_key2]) self.assertEquals(output.number_of_writes(), 38)
def test_get_submission_by_talk_and_conf(self): self.create_conference() t1 = talk.Talk() t1.title = "Talk T1" t1.put() sub_key1 = submissionrecord.make_submission(t1.key, self.c.key, "track", "format") t2 = talk.Talk() t2.title = "Unsubmitted" t2.put() self.assertEquals( sub_key1, submissionrecord.get_submission_by_talk_and_conf( t1.key, "TestConf")) self.assertEquals( None, submissionrecord.get_submission_by_talk_and_conf( t2.key, "TestConf")) # does not get listed for other conferences c2 = conference.Conference() c2.name = "OtherConf" c2.put() self.assertEquals( None, submissionrecord.get_submission_by_talk_and_conf( t1.key, "OtherConf")) self.assertEquals( None, submissionrecord.get_submission_by_talk_and_conf( t2.key, "OtherConf"))
def test_new_track(self): c = conference.Conference() c.name = "TestConf" c.put() self.assertEquals(c.track_options(), {}) self.assertEquals(c.track_objects(), []) to = confoptions.make_conference_track(c.key, "New Track") self.assertEquals(to.shortname(), "Option1") self.assertEquals(to.full_text(), "New Track") self.assertEquals(3, to.slots) self.assertEquals(c.track_options(), {"Option1": "New Track"}) tracks = c.track_objects() self.assertEquals(len(tracks), 1) self.assertIsInstance(tracks[0], confoptions.TrackOption) self.assertEquals(tracks[0].shortname(), "Option1") self.assertEquals(tracks[0].full_text(), "New Track") confoptions.make_conference_track(c.key, "Another track") self.assertEquals(c.track_options(), {"Option1": "New Track", "Option2": "Another track"}) tracks = c.track_objects() self.assertEquals(len(tracks), 2) self.assertIsInstance(tracks[1], confoptions.TrackOption) self.assertEquals(tracks[0].shortname(), "Option1") self.assertEquals(tracks[0].full_text(), "New Track") self.assertEquals(tracks[1].shortname(), "Option2") self.assertEquals(tracks[1].full_text(), "Another track")
def test_speakers_who_have_submitted(self): c = conference.Conference() c.name = "TestConf" c.put() blank_speaker = speaker.make_new_speaker("rimmer@email") blank_speaker.name = "Arnold Rimmer" blank_speaker.put() t1 = talk.mk_talk(blank_speaker.key, "Talk T1") sub_key1 = submissionrecord.make_submission(t1, c.key, "track", "format") bioed = speaker.make_new_speaker("cat@email") bioed.name = "Arnold Rimmer" bioed.bio = "The Cat" bioed.put() t2 = talk.mk_talk(bioed.key, "Cat Talks") sub_key2 = submissionrecord.make_submission(t2, c.key, "track", "format") spk_list = speaker_checks.find_blank_bio_submissions(c.key) self.assertEquals(1, len(spk_list)) self.assertEquals("rimmer@email", spk_list[0].email)
def test_submissions_conference_map(self): self.create_conference() c2 = conference.Conference() c2.name = "Another Conf" c2.put() self.assertEquals(len(submissionrecord.get_subs_for_talk(self.t.key)), 0) self.assertEquals( len(submissionrecord.get_confences_talk_submitted_to(self.t.key)), 0) sub_key = submissionrecord.make_submission(self.t.key, self.c.key, "track", "format") self.assertEquals(len(submissionrecord.get_subs_for_talk(self.t.key)), 1) self.assertEquals( len(submissionrecord.submissions_conference_map(self.t.key)), 1) self.assertEquals( submissionrecord.submissions_conference_map( self.t.key)[sub_key.urlsafe()], "TestConf") sub_key = submissionrecord.make_submission(self.t.key, c2.key, "track", "format") self.assertEquals(len(submissionrecord.get_subs_for_talk(self.t.key)), 2) self.assertEquals( len(submissionrecord.submissions_conference_map(self.t.key)), 2) self.assertEquals( submissionrecord.submissions_conference_map( self.t.key)[sub_key.urlsafe()], "Another Conf")
def test_get_conf_by_shortname(self): self.assertTrue(confdb.get_conf_by_name("WC2016") is None) new_conf = conference.Conference() new_conf.name = "WorldConf 2016" new_conf.shortname = "WC2016" new_conf.put() self.assertTrue(confdb.get_conf_by_shortname("WC2016") is not None)
def test_has_review_rights(self): c = conference.Conference() c.name = "TestConf" c.put() self.assertFalse(c.user_rights().has_review_rights("User1")) c.user_rights().add_permission("User1", userrightsnames.ROUND1_REVIEWER) self.assertTrue(c.user_rights().has_review_rights("User1")) self.assertFalse(c.user_rights().has_review_rights("User2")) c.user_rights().add_permission("User2", userrightsnames.ROUND2_REVIEWER) self.assertTrue(c.user_rights().has_review_rights("User2")) self.assertFalse(c.user_rights().has_review_rights("User3")) c.user_rights().add_permission("User3", userrightsnames.ROUND1_DECISION) self.assertTrue(c.user_rights().has_review_rights("User3")) c.user_rights().drop_all_permissions("User3") self.assertFalse(c.user_rights().has_review_rights("User3")) c.user_rights().add_permission("User3", userrightsnames.ROUND2_DECISION) self.assertTrue(c.user_rights().has_review_rights("User3")) c.user_rights().drop_all_permissions("User3") self.assertFalse(c.user_rights().has_review_rights("User3")) c.user_rights().add_permission("User3", userrightsnames.ROUND1_FULL_VIEW) self.assertTrue(c.user_rights().has_review_rights("User3")) c.user_rights().drop_all_permissions("User3") self.assertFalse(c.user_rights().has_review_rights("User3")) c.user_rights().add_permission("User3", userrightsnames.ROUND2_FULL_VIEW) self.assertTrue(c.user_rights().has_review_rights("User3"))
def common_data_setup(self): self.c = conference.Conference() self.c.name = "TestConf" self.c.put() # Set up the scenario t1 = talk.Talk() t1.title = "Talk1 - No duplicate votes" t1.put() subs_key1 = submissionrecord.make_submission(t1.key, self.c.key, "track", "format") self.assertEquals( len(submissionrecord.retrieve_conference_submissions(self.c.key)), 1) t2 = talk.Talk() t2.title = "Talk2 - Allan duplicate votes" t2.put() subs_key2 = submissionrecord.make_submission(t2.key, self.c.key, "track", "format") self.assertEquals( len(submissionrecord.retrieve_conference_submissions(self.c.key)), 2) return [subs_key1, subs_key2]
def setUp(self): self.testbed = testbed.Testbed() self.testbed.activate() self.testbed.init_datastore_v3_stub() self.testbed.init_memcache_stub() self.conference = conference.Conference() self.conference.name = "TestConf" self.conference.put()
def test_RetreiveAllConference(self): self.assertEquals(len(confdb.retrieve_all_conferences()), 0) new_conf = conference.Conference() new_conf.name = "WorldConf 2016" new_conf.put() self.assertEquals(len(confdb.retrieve_all_conferences()), 1)
def test_max_co_speakers(self): c = conference.Conference() c.name = "TestConf" c.put() self.assertEquals(3, c.max_cospeakers()) c.set_max_cospeakers(1) self.assertEquals(1, c.max_cospeakers())
def test_max_submissions(self): new_conf = conference.Conference() new_conf.name = "WorldConf 2016" new_conf.put() self.assertEquals(new_conf.max_submissions(), 3) new_conf.set_max_submissions(1) self.assertEquals(new_conf.max_submissions(), 1)
def test_contact_email(self): new_conf = conference.Conference() new_conf.name = "WorldConf 2016" new_conf.put() self.assertEquals(new_conf.contact_email(), "") new_conf.set_contact_email("[email protected]_lib.com") self.assertEquals(new_conf.contact_email(), "[email protected]_lib.com")
def test_conference_options(self): c = conference.Conference() c.name = "TestConf" c.put() self.assertEquals(c.max_submissions(), 3) self.assertFalse(c.conf_review_comments_visible) self.assertTrue(c.pays_expenses())
def test_counter(self): c = conference.Conference() c.name = "TestConf" c.put() self.assertEquals(confoptions.get_next_counter(c.key), 1) self.assertEquals(confoptions.get_next_counter(c.key), 2) self.assertEquals(confoptions.get_next_counter(c.key), 3)
def test_has_special_rights(self): c = conference.Conference() c.name = "TestConf" c.put() rights = openrights.OpenRights(c.key) self.assertTrue(rights.has_special_rights("Bert")) self.assertTrue(rights.has_special_rights("Jane")) self.assertTrue(rights.has_special_rights("Voldemort"))
def test_close_and_finalise(self): self.assertEquals(confdb.count_conferences(), 0) new_conf = conference.Conference() new_conf.name = "WorldConf 2016" new_conf.put() # No submissions so none outstanding new_conf.finish_reviews() self.assertTrue(new_conf.is_reviewing_compete)
def mk_conference(self): c = conference.Conference() c.name = "Allans conference_lib" c.shortname = "Allans" c.dates = "1-2 January 2017" c.creator_id = "Harry1" c.put() return c
def test_retrieve_duplicate_report(self): c = conference.Conference() c.name = "TestConf" c.put() self.assertEquals(dedupvotes.retrieve_duplicate_report(c.key), None) dedupvotes.generate_duplicate_vote_report(c.key, 1) self.assertNotEquals(dedupvotes.retrieve_duplicate_report(c.key), None)
def test_list_permission_holders(self): c = conference.Conference() c.name = "TestConf" c.put() c.user_rights().add_permission("One", "Permission") self.assertEquals(c.user_rights().list_permission_holders(), ["One"]) c.user_rights().add_permission("Two", "More Permission") self.assertEquals(c.user_rights().list_permission_holders(), ["One", "Two"])
def test_retreive_all_conferences_by_state(self): self.assertEquals(len(confdb.retrieve_all_conferences()), 0) new_conf = conference.Conference() new_conf.name = "WorldConf 2016" new_conf.put() self.assertEquals( len(confdb.retrieve_all_conferences_by_state("Closed")), 1) self.assertEquals( len(confdb.retrieve_all_conferences_by_state("Open")), 0) another_conf = conference.Conference() another_conf.name = "WorldConf 2017" another_conf.put() self.assertEquals( len(confdb.retrieve_all_conferences_by_state("Closed")), 2) self.assertEquals( len(confdb.retrieve_all_conferences_by_state("Open")), 0) new_conf.open_for_submissions() new_conf.put() self.assertEquals( len(confdb.retrieve_all_conferences_by_state("Closed")), 1) self.assertEquals( len(confdb.retrieve_all_conferences_by_state("Open")), 1) new_conf.close_submissions() new_conf.put() self.assertEquals( len(confdb.retrieve_all_conferences_by_state("Closed")), 2) self.assertEquals( len(confdb.retrieve_all_conferences_by_state("Open")), 0) new_conf.start_round1_reviews() new_conf.put() self.assertEquals( len(confdb.retrieve_all_conferences_by_state("Closed")), 1) self.assertEquals( len(confdb.retrieve_all_conferences_by_state("Open")), 0) self.assertEquals( len(confdb.retrieve_all_conferences_by_state("Round1Reviews")), 1)
def data_setup(self): c = conference.Conference() c.name = "TestConf" c.put() t = talk.Talk() t.title = "A testing talk" t.put() return c, t
def test_review_toggle(self): new_conf = conference.Conference() new_conf.name = "WorldConf 2016" new_conf.put() self.assertFalse(new_conf.comments_visible) new_conf.show_comments() self.assertTrue(new_conf.comments_visible) new_conf.hide_comments() self.assertFalse(new_conf.comments_visible)
def test_export_submission(self): c = conference.Conference() c.name = "TestConf" c.put() track1 = confoptions.make_conference_track(c.key, "track") format1 = confoptions.make_conference_option(confoptions.TalkFormatOption, c.key, "lecture") duration1 = confoptions.make_conference_option(confoptions.DurationOption, c.key, "10mins") expenses1 = confoptions.make_conference_option(confoptions.ExpenseOptions, c.key, "Long haul") s = speaker.make_new_speaker("*****@*****.**") s.name = 'Arnold "J" Rimmer' s.telephone = "051 652 0538" s.address = "Cabin 42, Deck 3, Red Dwarf" s.set_field("affiliation", "Mining Corp") s.set_field("twitter", "@arnold") s.bio = "Arnold 'J' Rimmer joined Mining Corp (Space Division) at, what now seems, a very young age." s.put() t = talk.Talk(parent=s.key) t.title = "A testing talk" t.set_field(talk.SHORT_SYNOPSIS, "A few words about the tests you need") t.set_field(talk.LONG_SYNOPSIS, "Many more words about testing.... 1, 2, 3") t.put() sub_key = submissionrecord.make_submission_plus(t.key, c.key, track1.shortname(), format1.shortname(), duration1.shortname(), expenses1.shortname()) cospeak = cospeaker.make_cospeaker(sub_key, "Harry Potter", "*****@*****.**") output = MockOutStream() exportcsv.write_sub(output, sub_key.get()) self.assertEquals(output.sequence[0], 'No decision, ') self.assertEquals(output.sequence[1], "Arnold 'J' Rimmer, ") self.assertEquals(output.sequence[2], '[email protected], ') self.assertEquals(output.sequence[3], '051 652 0538, ') self.assertEquals(output.sequence[4], '"Cabin 42, Deck 3, Red Dwarf", ') self.assertEquals(output.sequence[5], 'Harry Potter, ') self.assertEquals(output.sequence[6], ', ') self.assertEquals(output.sequence[7], 'Mining Corp, ') self.assertEquals(output.sequence[8], '@arnold, ') self.assertEquals(output.sequence[9], """"Arnold 'J' Rimmer joined Mining Corp (Space Division) at, what now seems, a very young age.", """) self.assertEquals(output.sequence[10], 'None, ') self.assertEquals(output.sequence[11], 'A testing talk, ') self.assertEquals(output.sequence[12], "A few words about the tests you need, ") self.assertEquals(output.sequence[13], '"Many more words about testing.... 1, 2, 3", ') self.assertEquals(output.sequence[14], 'track, ') self.assertEquals(output.sequence[15], 'lecture, ') self.assertEquals(output.sequence[16], '10mins, ') self.assertEquals(output.sequence[17], 'Long haul, ') self.assertEquals(output.number_of_writes(), 18)
def create_conference(self): self.c = conference.Conference() self.c.name = "TestConf" self.c.put() self.s = speaker.make_new_speaker("mail@email") self.s.name = "Arnold Rimmer" self.s.put() self.t = talk.Talk(parent=self.s.key) self.t.title = "A testing talk" self.t.put()