def setUp(self): super(TestAbstractSubmission, self).setUp() self._startDBReq() # Create few users ah = AvatarHolder() # Create dummy avatars in obj._avatarN self._avatars = [] for i in xrange(1, 5): avatar = Avatar() avatar.setName("fake-%d" % i) avatar.setSurName("fake") avatar.setOrganisation("fake") avatar.setLang("en_GB") avatar.setEmail("*****@*****.**" % i) avatar.setId("fake-%d" % i) ah.add(avatar) self._avatars.append(avatar) setattr(self, '_avatar%d' % i, avatar) # Create a conference category = conference.CategoryManager().getById('0') self._conf = category.newConference(self._avatar1) self._conf.setTimezone('UTC') sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC')) ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC')) self._conf.setDates(sd, ed) ch = ConferenceHolder() ch.add(self._conf) self._stopDBReq()
def testTplConditions(self): #test adding and removing conditions to templates from MaKaC.review import NotificationTemplate tpl1 = NotificationTemplate() tpl2 = NotificationTemplate() absMgr = self._conf.getAbstractMgr() absMgr.addNotificationTpl(tpl1) absMgr.addNotificationTpl(tpl2) from MaKaC.review import NotifTplCondAccepted, NotifTplCondRejected cond1 = NotifTplCondAccepted(contribType=self._contribTypeOral) cond2 = NotifTplCondRejected() tpl1.addCondition(cond1) tpl2.addCondition(cond2) from MaKaC.user import Avatar submitter = Avatar() submitter.setId("submitter") abs1 = absMgr.newAbstract(submitter) tplRes = absMgr.getNotifTplForAbstract(abs1) self.assert_(tplRes is None) abs1.accept(submitter, self._track1, self._contribTypeOral) self.assert_(absMgr.getNotifTplForAbstract(abs1) == tpl1) abs2 = absMgr.newAbstract(submitter) abs2.accept(submitter, self._track1, self._contribTypePoster) self.assert_(not absMgr.getNotifTplForAbstract(abs2)) abs3 = absMgr.newAbstract(submitter) abs3.reject(submitter) self.assert_(absMgr.getNotifTplForAbstract(abs3) == tpl2)
def setUp( self ): from MaKaC.user import Avatar a = Avatar() a.setId("creator") from MaKaC.conference import Conference self._conf = Conference( a ) self._conf.setTimezone('UTC')
def setUp(self): super(TestAuthentication, self).setUp() with self._context("database"): # Create few users and groups gh = GroupHolder() ah = AvatarHolder() self._authMgr = AuthenticatorMgr() for i in xrange(1, 3): group = Group() group.setName("fake-group-%d" % i) group.setDescription("fake") group.setEmail("*****@*****.**" % i) group.setId("fake-group-%d" % i) avatar = Avatar() avatar.setName("fake-%d" % i) avatar.setSurName("fake") avatar.setOrganisation("fake") avatar.setLang("en_GB") avatar.setEmail("*****@*****.**" % i) avatar.setId("fake-%d" % i) avatar.activateAccount() group.addMember(avatar) ah.add(avatar) gh.add(group) identity = self._authMgr.createIdentity( LoginInfo("fake-%d" % i, "fake-%d" % i), avatar, "Local") self._authMgr.add(identity)
def test(self): idx=SCIndex() c1=Avatar() c1.setId("1") s1=Session() idx.index(c1,s1) self.assert_(s1 in idx.getSessions(c1)) self.assert_(len(idx.getSessions(c1))==1) c2=Avatar() c2.setId("2") idx.index(c2,s1) self.assert_(s1 in idx.getSessions(c1)) self.assert_(len(idx.getSessions(c1))==1) self.assert_(s1 in idx.getSessions(c2)) self.assert_(len(idx.getSessions(c2))==1) s2=Session() idx.index(c2,s2) self.assert_(s1 in idx.getSessions(c1)) self.assert_(len(idx.getSessions(c1))==1) self.assert_(s1 in idx.getSessions(c2)) self.assert_(s2 in idx.getSessions(c2)) self.assert_(len(idx.getSessions(c2))==2) idx.unindex(c2,s2) self.assert_(s1 in idx.getSessions(c1)) self.assert_(len(idx.getSessions(c1))==1) self.assert_(s1 in idx.getSessions(c2)) self.assert_(s2 not in idx.getSessions(c2)) self.assert_(len(idx.getSessions(c2))==1)
def setUp( self ): a = Avatar() a.setId("creator") self._categ = Category() self._conf = Conference( a ) self._conf.setId('a') self._conf.setDates(datetime(2000, 01, 01, tzinfo=timezone("UTC")),datetime(2020, 01, 01, tzinfo=timezone("UTC")))
def setUp(self): super(TestAuthentication, self).setUp() with self._context("database"): # Create few users and groups gh = GroupHolder() ah = AvatarHolder() self._authMgr = AuthenticatorMgr() for i in xrange(1, 3): group = Group() group.setName("fake-group-%d" % i) group.setDescription("fake") group.setEmail("*****@*****.**" % i) group.setId("fake-group-%d" % i) avatar = Avatar() avatar.setName("fake-%d" % i) avatar.setSurName("fake") avatar.setOrganisation("fake") avatar.setLang("en_GB") avatar.setEmail("*****@*****.**" % i) avatar.setId("fake-%d" % i) avatar.activateAccount() group.addMember(avatar) ah.add(avatar) gh.add(group) identity = self._authMgr.createIdentity(LoginInfo("fake-%d" % i, "fake-%d" % i), avatar, "Local") self._authMgr.add(identity)
def testTplConditions(self): # test adding and removing conditions to templates from MaKaC.review import NotificationTemplate tpl1 = NotificationTemplate() tpl2 = NotificationTemplate() absMgr = self._conf.getAbstractMgr() absMgr.addNotificationTpl(tpl1) absMgr.addNotificationTpl(tpl2) from MaKaC.review import NotifTplCondAccepted, NotifTplCondRejected cond1 = NotifTplCondAccepted(contribType=self._contribTypeOral) cond2 = NotifTplCondRejected() tpl1.addCondition(cond1) tpl2.addCondition(cond2) from MaKaC.user import Avatar submitter = Avatar() submitter.setId("submitter") abs1 = absMgr.newAbstract(submitter) tplRes = absMgr.getNotifTplForAbstract(abs1) self.assert_(tplRes is None) abs1.accept(submitter, self._track1, self._contribTypeOral) self.assert_(absMgr.getNotifTplForAbstract(abs1) == tpl1) abs2 = absMgr.newAbstract(submitter) abs2.accept(submitter, self._track1, self._contribTypePoster) self.assert_(not absMgr.getNotifTplForAbstract(abs2)) abs3 = absMgr.newAbstract(submitter) abs3.reject(submitter) self.assert_(absMgr.getNotifTplForAbstract(abs3) == tpl2)
def testTplCondAccNoneTrack(self): # test different possibilities when a condition has been stablished for # a notif tpl on none track from MaKaC.review import NotificationTemplate tpl1 = NotificationTemplate() absMgr = self._conf.getAbstractMgr() absMgr.addNotificationTpl(tpl1) from MaKaC.review import NotifTplCondAccepted cond1 = NotifTplCondAccepted(track=None, contribType=self._contribTypeOral) tpl1.addCondition(cond1) from MaKaC.user import Avatar submitter = Avatar() submitter.setId("submitter") abs1 = absMgr.newAbstract(submitter) abs1.accept(submitter, self._track1, self._contribTypeOral) self.assert_(absMgr.getNotifTplForAbstract(abs1) is None) abs2 = absMgr.newAbstract(submitter) abs2.accept(submitter, self._track1, self._contribTypePoster) self.assert_(absMgr.getNotifTplForAbstract(abs2) is None) abs3 = absMgr.newAbstract(submitter) abs3.accept(submitter, None, self._contribTypeOral) self.assert_(absMgr.getNotifTplForAbstract(abs3) == tpl1)
def testTplCondAccAnyTrack(self): #test different possibilities when a condition has been stablished for # a notif tpl on any track from MaKaC.review import NotificationTemplate tpl1 = NotificationTemplate() absMgr = self._conf.getAbstractMgr() absMgr.addNotificationTpl(tpl1) from MaKaC.review import NotifTplCondAccepted cond1 = NotifTplCondAccepted(contribType=self._contribTypeOral) tpl1.addCondition(cond1) from MaKaC.user import Avatar submitter = Avatar() submitter.setId("submitter") abs1 = absMgr.newAbstract(submitter) abs1.accept(submitter, self._track1, self._contribTypeOral) self.assert_(absMgr.getNotifTplForAbstract(abs1) == tpl1) abs2 = absMgr.newAbstract(submitter) abs2.accept(submitter, self._track1, self._contribTypePoster) self.assert_(absMgr.getNotifTplForAbstract(abs2) is None) abs3 = absMgr.newAbstract(submitter) abs3.accept(submitter, self._track2, self._contribTypeOral) self.assert_(absMgr.getNotifTplForAbstract(abs3) == tpl1) abs4 = absMgr.newAbstract(submitter) abs4.accept(submitter, None, self._contribTypeOral) self.assert_(absMgr.getNotifTplForAbstract(abs4) == tpl1)
def testBasic(self): c1=Contribution() self._conf.addContribution(c1) av1,av2=Avatar(),Avatar() av1.setId("1") av2.setId("2") self.assert_(not c1.canUserSubmit(av1)) self.assert_(not c1.canUserSubmit(av2)) self.assert_(len(c1.getSubmitterList())==0) c1.grantSubmission(av1) self.assert_(c1.canUserSubmit(av1)) self.assert_(not c1.canUserSubmit(av2)) self.assert_(len(c1.getSubmitterList())==1) self.assert_(av1 in c1.getSubmitterList()) self.assert_(av2 not in c1.getSubmitterList()) c1.revokeSubmission(av2) self.assert_(c1.canUserSubmit(av1)) self.assert_(not c1.canUserSubmit(av2)) self.assert_(len(c1.getSubmitterList())==1) self.assert_(av1 in c1.getSubmitterList()) self.assert_(av2 not in c1.getSubmitterList()) c1.revokeSubmission(av1) self.assert_(not c1.canUserSubmit(av1)) self.assert_(not c1.canUserSubmit(av2)) self.assert_(len(c1.getSubmitterList())==0)
def setUp( self ): from MaKaC.user import Avatar a = Avatar() a.setId("creator") from MaKaC.conference import Conference self._conf=Conference(a) self._conf.setTimezone('UTC') self._conf.setDates(datetime(2000,1,1,tzinfo=timezone('UTC')),datetime(2020,1,1,tzinfo=timezone('UTC')))
def setUp(self): a = Avatar() a.setId("creator") self._conf=Conference(a) self._conf.setTimezone('UTC') sd=datetime(2004, 01, 01, 10, 00, tzinfo=timezone('UTC')) ed=datetime(2004, 01, 05, 10, 00, tzinfo=timezone('UTC')) self._conf.setDates(sd,ed)
def setUp(self): a = Avatar() a.setId("creator") self._conf = Conference(a) self._conf.setTimezone('UTC') sd = datetime(2004, 01, 01, 10, 00, tzinfo=timezone('UTC')) ed = datetime(2004, 01, 05, 10, 00, tzinfo=timezone('UTC')) self._conf.setDates(sd, ed)
def testAddTC( self ): from MaKaC.user import Avatar tc1 = Avatar() tc1.setId( "tc1" ) self._track1.addCoordinator( tc1 ) self.assert_( len(self._track1.getCoordinatorList()) == 1 ) self.assert_( tc1 in self._track1.getCoordinatorList() ) self.assert_( self._track1 in self._conf.getCoordinatedTracks( tc1 ) )
def setUp( self ): from MaKaC.user import Avatar cr = Avatar() cr.setId( "creator" ) from MaKaC.conference import Conference, Track self._conf = Conference( cr ) self._track1 = Track() self._track1.setId( "1" ) self._conf.addTrack( self._track1 )
def setUp( self ): a = Avatar() a.setId("creator") self._conf = ConferenceFacade( a ) self._conf.setId('a') self._conf.setTimezone('UTC') self._conf.setDates(datetime(2009, 9, 21, 16, 0 ,0, tzinfo=timezone("UTC")), datetime(2009, 9, 21, 19, 0 ,0, tzinfo=timezone("UTC")))
class TestBasicManagement(unittest.TestCase): """Tests the basic conference management functions """ def setUp( self ): self._creator=Avatar() self._creator.setId("creator") self._conf=Conference(self._creator) self._conf.setTimezone('UTC') confTZ = self._conf.getTimezone() sd = timezone(confTZ).localize(datetime(2000, 1, 1)) sdUTC = sd.astimezone(timezone('UTC')) ed = timezone(confTZ).localize(datetime(2020, 1, 1)) edUTC = ed.astimezone(timezone('UTC')) self._conf.setDates(sdUTC,edUTC) def testAddRemoveSessions(self): s1,s2=Session(),Session() self._conf.addSession(s1) self._conf.addSession(s2) self.assert_(s1 in self._conf.getSessionList()) self.assert_(s1==self._conf.getSessionById(s1.getId())) self.assert_(s2 in self._conf.getSessionList()) self.assert_(s2==self._conf.getSessionById(s2.getId())) self._conf.removeSession(s1) self.assert_(s1 not in self._conf.getSessionList()) self.assert_(None==self._conf.getSessionById(s1.getId())) self.assert_(s2 in self._conf.getSessionList()) self.assert_(s2==self._conf.getSessionById(s2.getId())) c1,c2,c3=Contribution(),Contribution(),Contribution() self._conf.addSession(s1) s1.addContribution(c1) s1.addContribution(c2) s2.addContribution(c3) self.assert_(s1 in self._conf.getSessionList()) self.assert_(s1==self._conf.getSessionById(s1.getId())) self.assert_(s2 in self._conf.getSessionList()) self.assert_(s2==self._conf.getSessionById(s2.getId())) self.assert_(c1 in self._conf.getContributionList()) self.assert_(c2 in self._conf.getContributionList()) self.assert_(c3 in self._conf.getContributionList()) self.assert_(c1 in s1.getContributionList()) self.assert_(c2 in s1.getContributionList()) self.assert_(c3 in s2.getContributionList()) self._conf.removeSession(s1) self.assert_(s1 not in self._conf.getSessionList()) self.assert_(s2 in self._conf.getSessionList()) self.assert_(c1 in self._conf.getContributionList()) self.assert_(c2 in self._conf.getContributionList()) self.assert_(c3 in self._conf.getContributionList()) self.assert_(c1 not in s1.getContributionList()) self.assert_(c1.getSession()==None) self.assert_(c2.getSession()==None) self.assert_(c2 not in s1.getContributionList()) self.assert_(c3 in s2.getContributionList())
class TestBasicManagement(unittest.TestCase): """Tests the basic conference management functions """ def setUp(self): self._creator = Avatar() self._creator.setId("creator") self._conf = Conference(self._creator) self._conf.setTimezone('UTC') confTZ = self._conf.getTimezone() sd = timezone(confTZ).localize(datetime(2000, 1, 1)) sdUTC = sd.astimezone(timezone('UTC')) ed = timezone(confTZ).localize(datetime(2020, 1, 1)) edUTC = ed.astimezone(timezone('UTC')) self._conf.setDates(sdUTC, edUTC) def testAddRemoveSessions(self): s1, s2 = Session(), Session() self._conf.addSession(s1) self._conf.addSession(s2) self.assert_(s1 in self._conf.getSessionList()) self.assert_(s1 == self._conf.getSessionById(s1.getId())) self.assert_(s2 in self._conf.getSessionList()) self.assert_(s2 == self._conf.getSessionById(s2.getId())) self._conf.removeSession(s1) self.assert_(s1 not in self._conf.getSessionList()) self.assert_(None == self._conf.getSessionById(s1.getId())) self.assert_(s2 in self._conf.getSessionList()) self.assert_(s2 == self._conf.getSessionById(s2.getId())) c1, c2, c3 = Contribution(), Contribution(), Contribution() self._conf.addSession(s1) s1.addContribution(c1) s1.addContribution(c2) s2.addContribution(c3) self.assert_(s1 in self._conf.getSessionList()) self.assert_(s1 == self._conf.getSessionById(s1.getId())) self.assert_(s2 in self._conf.getSessionList()) self.assert_(s2 == self._conf.getSessionById(s2.getId())) self.assert_(c1 in self._conf.getContributionList()) self.assert_(c2 in self._conf.getContributionList()) self.assert_(c3 in self._conf.getContributionList()) self.assert_(c1 in s1.getContributionList()) self.assert_(c2 in s1.getContributionList()) self.assert_(c3 in s2.getContributionList()) self._conf.removeSession(s1) self.assert_(s1 not in self._conf.getSessionList()) self.assert_(s2 in self._conf.getSessionList()) self.assert_(c1 in self._conf.getContributionList()) self.assert_(c2 in self._conf.getContributionList()) self.assert_(c3 in self._conf.getContributionList()) self.assert_(c1 not in s1.getContributionList()) self.assert_(c1.getSession() == None) self.assert_(c2.getSession() == None) self.assert_(c2 not in s1.getContributionList()) self.assert_(c3 in s2.getContributionList())
def setUp(self): a = Avatar() a.setId("creator") self._conf = ConferenceFacade(a) self._conf.setId('a') self._conf.setTimezone('UTC') self._conf.setDates( datetime(2009, 9, 21, 16, 0, 0, tzinfo=timezone("UTC")), datetime(2009, 9, 21, 19, 0, 0, tzinfo=timezone("UTC")))
class TestContributionSubmitterIndex(unittest.TestCase): """ """ def setUp( self ): self._creator = Avatar() self._creator.setId("creator") self._categ = Category() self._conf=Conference(self._creator) self._conf.setId('a') self._conf.setTimezone('UTC') self._categ._addConference(self._conf) def testBasic(self): c1,c2=Contribution(),Contribution() av1,av2=Avatar(),Avatar() av1.setId("1") av2.setId("2") self.assert_(len(self._conf.getContribsForSubmitter(av1))==0) self.assert_(len(self._conf.getContribsForSubmitter(av2))==0) self._conf.addContribution(c1) self.assert_(len(self._conf.getContribsForSubmitter(av1))==0) self.assert_(len(self._conf.getContribsForSubmitter(av2))==0) c1.grantSubmission(av1) self.assert_(len(self._conf.getContribsForSubmitter(av1))==1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2))==0) c2.grantSubmission(av2) self.assert_(len(self._conf.getContribsForSubmitter(av1))==1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2))==0) self._conf.addContribution(c2) self.assert_(len(self._conf.getContribsForSubmitter(av1))==1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2))==1) self.assert_(c2 in self._conf.getContribsForSubmitter(av2)) c1.grantSubmission(av2) self.assert_(len(self._conf.getContribsForSubmitter(av1))==1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2))==2) self.assert_(c1 in self._conf.getContribsForSubmitter(av2)) self.assert_(c2 in self._conf.getContribsForSubmitter(av2)) c1.revokeSubmission(av2) self.assert_(len(self._conf.getContribsForSubmitter(av1))==1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2))==1) self.assert_(c1 not in self._conf.getContribsForSubmitter(av2)) self.assert_(c2 in self._conf.getContribsForSubmitter(av2)) self._conf.removeContribution(c2) self.assert_(len(self._conf.getContribsForSubmitter(av1))==1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2))==0) self.assert_(c1 not in self._conf.getContribsForSubmitter(av2)) self.assert_(c2 not in self._conf.getContribsForSubmitter(av2))
class TestSubmissionPrivileges(unittest.TestCase): """Tests different scenarios concerning the material submission privileges """ def setUp( self ): self._creator=Avatar() self._creator.setId("creator") self._conf=Conference(self._creator) sd=datetime(2004, 01, 01, 10, 00, tzinfo=timezone("UTC")) ed=datetime(2004, 01, 05, 10, 00, tzinfo=timezone("UTC")) self._conf.setDates(sd,ed) def testBasic(self): c1=Contribution() self._conf.addContribution(c1) av1,av2=Avatar(),Avatar() av1.setId("1") av2.setId("2") self.assert_(not c1.canUserSubmit(av1)) self.assert_(not c1.canUserSubmit(av2)) self.assert_(len(c1.getSubmitterList())==0) c1.grantSubmission(av1) self.assert_(c1.canUserSubmit(av1)) self.assert_(not c1.canUserSubmit(av2)) self.assert_(len(c1.getSubmitterList())==1) self.assert_(av1 in c1.getSubmitterList()) self.assert_(av2 not in c1.getSubmitterList()) c1.revokeSubmission(av2) self.assert_(c1.canUserSubmit(av1)) self.assert_(not c1.canUserSubmit(av2)) self.assert_(len(c1.getSubmitterList())==1) self.assert_(av1 in c1.getSubmitterList()) self.assert_(av2 not in c1.getSubmitterList()) c1.revokeSubmission(av1) self.assert_(not c1.canUserSubmit(av1)) self.assert_(not c1.canUserSubmit(av2)) self.assert_(len(c1.getSubmitterList())==0) def testAccContrib(self): #tests that when a contribution comes from an accepted abstract the # abstract submitters are also granted with submission privileges # for the contribution av1=Avatar() av1.setId("1") av2=Avatar() av2.setId("2") abs=self._conf.getAbstractMgr().newAbstract(av1) abs.accept(self._creator,None,None) c=abs.getContribution() self.assert_(c.canUserSubmit(av1)) self.assert_(not c.canUserSubmit(av2)) c.grantSubmission(av2) self.assert_(c.canUserSubmit(av1)) self.assert_(c.canUserSubmit(av2))
def setUp(self): super(TestAbstractJudgements, self).setUp() self._startDBReq() # Get dummy user and create another one ah = AvatarHolder() avatar1 = ah.getById(0) avatar2 = Avatar() avatar2.setName("fake-2") avatar2.setSurName("fake") avatar2.setOrganisation("fake") avatar2.setLang("en_GB") avatar2.setEmail("*****@*****.**") avatar2.setId("fake-2") ah.add(avatar2) setattr(self, '_avatar1', avatar1) setattr(self, '_avatar2', avatar2) # Create a conference category = conference.CategoryManager().getById('0') self._conf = category.newConference(self._avatar1) self._conf.setTimezone('UTC') sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC')) ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC')) self._conf.setDates(sd, ed) ch = ConferenceHolder() ch.add(self._conf) self._ctOral = conference.ContributionType("oral", "", self._conf) self._conf.addContribType(self._ctOral) self._track1 = self._conf.newTrack() self._track2 = self._conf.newTrack() self._track3 = self._conf.newTrack() self._abstract1 = self._conf.getAbstractMgr().newAbstract( self._avatar1) self._abstract2 = self._conf.getAbstractMgr().newAbstract( self._avatar1) self._abstract3 = self._conf.getAbstractMgr().newAbstract( self._avatar1) self._abstract4 = self._conf.getAbstractMgr().newAbstract( self._avatar1) self._abstract5 = self._conf.getAbstractMgr().newAbstract( self._avatar1) self._abstract1.setTracks([self._track1, self._track2, self._track3]) self._abstract2.setTracks([self._track1, self._track2]) self._abstract3.setTracks([self._track1]) self._abstract4.setTracks([self._track2, self._track3]) self._abstract5.setTracks([self._track3]) self._stopDBReq()
def setUp(self): a = Avatar() a.setId("creator") self._conf = Conference(a) self._conf.setId('a') category = Category() category.setId('1') self._conf.addOwner(category) catDateIdx = indexes.IndexesHolder().getIndex('categoryDate') catDateIdx.indexConf(self._conf) self._conf.setTimezone('UTC')
def setUp( self ): a = Avatar() a.setId("creator") self._conf = Conference( a ) self._conf.setId('a') category=Category() category.setId('1') self._conf.addOwner(category) catDateIdx = indexes.IndexesHolder().getIndex('categoryDate') catDateIdx.indexConf(self._conf) self._conf.setTimezone('UTC')
def testSimpleIndexing( self ): #adding a simple object to the index from MaKaC.user import Avatar av = Avatar() av.setId( "1" ) #the index needs the avatar to be uniquely identified from MaKaC.conference import Track t = Track() t.setId( "1" ) self._idx.indexCoordinator( av , t ) self.assert_( len(self._idx.getTracks( av )) == 1 ) self.assert_( t in self._idx.getTracks( av ) )
def testSimpleUnidexing( self ): #check that unindexing works properly from MaKaC.user import Avatar av = Avatar() av.setId( "1" ) #the index needs the avatar to be uniquely identified from MaKaC.conference import Track t = Track() t.setId( "1" ) self._idx.indexCoordinator( av , t ) self._idx.unindexCoordinator( av, t ) self.assert_( len(self._idx.getTracks( av )) == 0 )
class TestContributionSubmitterIndex(unittest.TestCase): """ """ def setUp(self): self._creator = Avatar() self._creator.setId("creator") self._categ = Category() self._conf = Conference(self._creator) self._conf.setId('a') self._conf.setTimezone('UTC') self._categ._addConference(self._conf) def testBasic(self): c1, c2 = Contribution(), Contribution() av1, av2 = Avatar(), Avatar() av1.setId("1") av2.setId("2") self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 0) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 0) self._conf.addContribution(c1) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 0) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 0) c1.grantSubmission(av1) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 0) c2.grantSubmission(av2) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 0) self._conf.addContribution(c2) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 1) self.assert_(c2 in self._conf.getContribsForSubmitter(av2)) c1.grantSubmission(av2) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 2) self.assert_(c1 in self._conf.getContribsForSubmitter(av2)) self.assert_(c2 in self._conf.getContribsForSubmitter(av2)) c1.revokeSubmission(av2) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 1) self.assert_(c1 not in self._conf.getContribsForSubmitter(av2)) self.assert_(c2 in self._conf.getContribsForSubmitter(av2)) self._conf.removeContribution(c2) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 0) self.assert_(c1 not in self._conf.getContribsForSubmitter(av2)) self.assert_(c2 not in self._conf.getContribsForSubmitter(av2))
def testRemoveTC( self ): from MaKaC.user import Avatar tc1 = Avatar() tc1.setId( "tc1" ) tc2 = Avatar() tc2.setId( "tc2" ) self._track1.addCoordinator( tc1 ) self._track1.addCoordinator( tc2 ) self._track1.removeCoordinator( tc1 ) self.assert_( tc1 not in self._track1.getCoordinatorList() ) self.assert_( tc2 in self._track1.getCoordinatorList() ) self.assert_( self._track1 not in self._conf.getCoordinatedTracks( tc1 ) ) self.assert_( self._track1 in self._conf.getCoordinatedTracks( tc2 ) )
def testUnindexingSeveralCoordinators( self ): from MaKaC.user import Avatar av1 = Avatar() av1.setId( "1" ) #the index needs the avatar to be uniquely identified av2 = Avatar() av2.setId( "2" ) #the index needs the avatar to be uniquely identified from MaKaC.conference import Track t1 = Track() t1.setId( "1" ) self._idx.indexCoordinator( av1 , t1 ) self._idx.indexCoordinator( av2 , t1 ) self._idx.unindexCoordinator( av1, t1 ) self.assert_( t1 not in self._idx.getTracks( av1 ) ) self.assert_( t1 in self._idx.getTracks( av2 ) )
def testIndexingSeveralCoordinators( self ): #adding 2 coordinators for the same track from MaKaC.user import Avatar av1 = Avatar() av1.setId( "1" ) #the index needs the avatar to be uniquely identified av2 = Avatar() av2.setId( "2" ) #the index needs the avatar to be uniquely identified from MaKaC.conference import Track t = Track() t.setId( "1" ) self._idx.indexCoordinator( av1 , t ) self._idx.indexCoordinator( av2 , t ) self.assert_( t in self._idx.getTracks( av1 ) ) self.assert_( t in self._idx.getTracks( av2 ) )
def testIndexingSeveralTracks( self ): #adding 1 coordinator for 2 tracks from MaKaC.user import Avatar av1 = Avatar() av1.setId( "1" ) #the index needs the avatar to be uniquely identified from MaKaC.conference import Track t1 = Track() t1.setId( "1" ) t2 = Track() t2.setId( "2" ) self._idx.indexCoordinator( av1 , t1 ) self._idx.indexCoordinator( av1 , t2 ) self.assert_( t1 in self._idx.getTracks( av1 ) ) self.assert_( t2 in self._idx.getTracks( av1 ) )
def testCoordination(self): session1,session2,session3=Session(),Session(),Session() self._conf.addSession(session1) self._conf.addSession(session2) c1,c2=Avatar(),Avatar() c1.setId("1") c2.setId("2") session1.addCoordinator(c1) self.assert_(c1 in session1.getCoordinatorList()) self.assert_(len(session1.getCoordinatorList())==1) self.assert_(session1.isCoordinator(c1)) self.assert_(not session1.isCoordinator(c2)) self.assert_(not session1.isCoordinator(None)) self.assert_(session1 in self._conf.getCoordinatedSessions(c1)) self.assert_(len(self._conf.getCoordinatedSessions(c1))==1) self.assert_(len(self._conf.getCoordinatedSessions(c2))==0) self._conf.addSessionCoordinator(session1,c1) self.assert_(c1 in session1.getCoordinatorList()) self.assert_(len(session1.getCoordinatorList())==1) self.assert_(session1.isCoordinator(c1)) self.assert_(not session1.isCoordinator(c2)) self.assert_(not session1.isCoordinator(None)) self.assert_(session1 in self._conf.getCoordinatedSessions(c1)) self.assert_(len(self._conf.getCoordinatedSessions(c1))==1) self.assert_(len(self._conf.getCoordinatedSessions(c2))==0) self._conf.addSessionCoordinator(session2,c2) self.assert_(c2 in session2.getCoordinatorList()) self.assert_(not session1.isCoordinator(c2)) self.assert_(session2 in self._conf.getCoordinatedSessions(c2)) self.assert_(len(self._conf.getCoordinatedSessions(c1))==1) self.assert_(len(self._conf.getCoordinatedSessions(c2))==1) self._conf.addSession(session3) session3.addCoordinator(c2) self.assert_(c2 in session3.getCoordinatorList()) self.assert_(not session1.isCoordinator(c2)) self.assert_(session3 in self._conf.getCoordinatedSessions(c2)) self.assert_(session2 in self._conf.getCoordinatedSessions(c2)) self.assert_(len(self._conf.getCoordinatedSessions(c1))==1) self.assert_(len(self._conf.getCoordinatedSessions(c2))==2) self._conf.removeSession(session1) self.assert_(session1 not in self._conf.getCoordinatedSessions(c1)) self.assert_(len(self._conf.getCoordinatedSessions(c1))==0) self.assert_(len(self._conf.getCoordinatedSessions(c2))==2) session2.removeCoordinator(c2) self.assert_(c2 not in session2.getCoordinatorList()) self.assert_(c2 in session3.getCoordinatorList()) self.assert_(session3 in self._conf.getCoordinatedSessions(c2)) self.assert_(session2 not in self._conf.getCoordinatedSessions(c2)) self.assert_(len(self._conf.getCoordinatedSessions(c1))==0) self.assert_(len(self._conf.getCoordinatedSessions(c2))==1)
def setUp(self): super(TestAbstractJudgements, self).setUp() self._startDBReq() # Get dummy user and create another one ah = AvatarHolder() avatar1 = ah.getById(0) avatar2 = Avatar() avatar2.setName("fake-2") avatar2.setSurName("fake") avatar2.setOrganisation("fake") avatar2.setLang("en_GB") avatar2.setEmail("*****@*****.**") avatar2.setId("fake-2") ah.add(avatar2) setattr(self, '_avatar1', avatar1) setattr(self, '_avatar2', avatar2) # Create a conference category = conference.CategoryManager().getById('0') self._conf = category.newConference(self._avatar1) self._conf.setTimezone('UTC') sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC')) ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC')) self._conf.setDates(sd, ed) ch = ConferenceHolder() ch.add(self._conf) self._ctOral = conference.ContributionType("oral", "", self._conf) self._conf.addContribType(self._ctOral) self._track1 = self._conf.newTrack() self._track2 = self._conf.newTrack() self._track3 = self._conf.newTrack() self._abstract1 = self._conf.getAbstractMgr().newAbstract(self._avatar1) self._abstract2 = self._conf.getAbstractMgr().newAbstract(self._avatar1) self._abstract3 = self._conf.getAbstractMgr().newAbstract(self._avatar1) self._abstract4 = self._conf.getAbstractMgr().newAbstract(self._avatar1) self._abstract5 = self._conf.getAbstractMgr().newAbstract(self._avatar1) self._abstract1.setTracks([self._track1, self._track2, self._track3]) self._abstract2.setTracks([self._track1, self._track2]) self._abstract3.setTracks([self._track1]) self._abstract4.setTracks([self._track2, self._track3]) self._abstract5.setTracks([self._track3]) self._stopDBReq()
def testAccContrib(self): #tests that when a contribution comes from an accepted abstract the # abstract submitters are also granted with submission privileges # for the contribution av1=Avatar() av1.setId("1") av2=Avatar() av2.setId("2") abs=self._conf.getAbstractMgr().newAbstract(av1) abs.accept(self._creator,None,None) c=abs.getContribution() self.assert_(c.canUserSubmit(av1)) self.assert_(not c.canUserSubmit(av2)) c.grantSubmission(av2) self.assert_(c.canUserSubmit(av1)) self.assert_(c.canUserSubmit(av2))
def setUp( self ): a=Avatar() a.setId("creator") self._conf=Conference(a) self._conf.setTimezone('UTC') self._conf.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC'))) self._conf.setEndDate(datetime(2004,1,1,13,0,tzinfo=timezone('UTC'))) self._session=Session() self._session.setStartDate(datetime(2004,1,1,11,0,tzinfo=timezone('UTC'))) self._session.setEndDate(datetime(2004,1,1,13,0,tzinfo=timezone('UTC'))) self._conf.addSession(self._session) self._slot1=SessionSlot(self._session) self._slot1.setStartDate(datetime(2004,1,1,11,0,tzinfo=timezone('UTC'))) self._slot1.setDuration(hours=1) self._session.addSlot(self._slot1) self._session.setScheduleType("poster") self._session.setContribDuration(1,0)
def testBasic(self): c1, c2 = Contribution(), Contribution() av1, av2 = Avatar(), Avatar() av1.setId("1") av2.setId("2") self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 0) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 0) self._conf.addContribution(c1) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 0) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 0) c1.grantSubmission(av1) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 0) c2.grantSubmission(av2) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 0) self._conf.addContribution(c2) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 1) self.assert_(c2 in self._conf.getContribsForSubmitter(av2)) c1.grantSubmission(av2) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 2) self.assert_(c1 in self._conf.getContribsForSubmitter(av2)) self.assert_(c2 in self._conf.getContribsForSubmitter(av2)) c1.revokeSubmission(av2) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 1) self.assert_(c1 not in self._conf.getContribsForSubmitter(av2)) self.assert_(c2 in self._conf.getContribsForSubmitter(av2)) self._conf.removeContribution(c2) self.assert_(len(self._conf.getContribsForSubmitter(av1)) == 1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2)) == 0) self.assert_(c1 not in self._conf.getContribsForSubmitter(av2)) self.assert_(c2 not in self._conf.getContribsForSubmitter(av2))
def testBasic(self): c1,c2=Contribution(),Contribution() av1,av2=Avatar(),Avatar() av1.setId("1") av2.setId("2") self.assert_(len(self._conf.getContribsForSubmitter(av1))==0) self.assert_(len(self._conf.getContribsForSubmitter(av2))==0) self._conf.addContribution(c1) self.assert_(len(self._conf.getContribsForSubmitter(av1))==0) self.assert_(len(self._conf.getContribsForSubmitter(av2))==0) c1.grantSubmission(av1) self.assert_(len(self._conf.getContribsForSubmitter(av1))==1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2))==0) c2.grantSubmission(av2) self.assert_(len(self._conf.getContribsForSubmitter(av1))==1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2))==0) self._conf.addContribution(c2) self.assert_(len(self._conf.getContribsForSubmitter(av1))==1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2))==1) self.assert_(c2 in self._conf.getContribsForSubmitter(av2)) c1.grantSubmission(av2) self.assert_(len(self._conf.getContribsForSubmitter(av1))==1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2))==2) self.assert_(c1 in self._conf.getContribsForSubmitter(av2)) self.assert_(c2 in self._conf.getContribsForSubmitter(av2)) c1.revokeSubmission(av2) self.assert_(len(self._conf.getContribsForSubmitter(av1))==1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2))==1) self.assert_(c1 not in self._conf.getContribsForSubmitter(av2)) self.assert_(c2 in self._conf.getContribsForSubmitter(av2)) self._conf.removeContribution(c2) self.assert_(len(self._conf.getContribsForSubmitter(av1))==1) self.assert_(c1 in self._conf.getContribsForSubmitter(av1)) self.assert_(len(self._conf.getContribsForSubmitter(av2))==0) self.assert_(c1 not in self._conf.getContribsForSubmitter(av2)) self.assert_(c2 not in self._conf.getContribsForSubmitter(av2))
def setUp( self ): # create a context, for storing autoOps ContextManager.create() ContextManager.set('autoOps', []) a = Avatar() a.setId("creator") self._conf = ConferenceFacade( a ) self._conf.setId('a') self._conf.setTimezone('UTC') self._conf.setDates(datetime(2009, 9, 21, 16, 0 ,0, tzinfo=timezone("UTC")), datetime(2009, 9, 21, 19, 0 ,0, tzinfo=timezone("UTC"))) self._slot1_sDate = datetime(2009, 9, 21, 17, 0, 0, tzinfo=timezone("UTC")) self._slot1_eDate = datetime(2009, 9, 21, 18, 0, 0, tzinfo=timezone("UTC")) self._slot2_sDate = datetime(2009, 9, 21, 18, 0, 0, tzinfo=timezone("UTC")) self._slot2_eDate = datetime(2009, 9, 21, 19, 0, 0, tzinfo=timezone("UTC")) self._slot2_laterDate = datetime(2009, 9, 21, 20, 0, 0, tzinfo=timezone("UTC")) self._session1 = Session() self._session1.setValues({ 'sDate': self._slot1_sDate, 'eDate': self._slot1_eDate }) self._conf.addSession(self._session1) self._slot1 = self._session1.getSlotById(0) self._slot2 = SessionSlot(self._session1) self._slot2.setValues({ 'sDate': self._slot2_sDate, 'eDate': self._slot2_eDate }); self._session1.addSlot(self._slot2)
class TestElectronicAgreement(IndicoTestCase): _requires = ['db.Database', 'util.RequestEnvironment', Collaboration_Feature] def setUp(self): ''' Create a conference, 0 Add 2 contributions to this conference, 0 and 1 To contribution 0 - Add 2 speakers, person1 and person2 To contribution 1 - Add 1 speaker, person1 ''' super(TestElectronicAgreement, self).setUp() with self._context('database', 'request'): # Create few users self._creator = Avatar({"name":"God", "email":"*****@*****.**"}) self._creator.setId("creator") # Set God as admin AdminList.getInstance().getList().append(self._creator) self.person1 = Avatar({"name":"giuseppe", "email":"*****@*****.**"}) self.person1.setId("spk1") self.person2 = Avatar({"name":"gabriele", "email":"*****@*****.**"}) self.person1.setId("spk2") self.person3 = Avatar({"name":"lorenzo", "email":"*****@*****.**"}) self.person1.setId("spk3") self.person4 = Avatar({"name":"silvio", "email":"*****@*****.**"}) self.person1.setId("spk4") ah = AvatarHolder() ah.add(self.person1) ah.add(self.person2) ah.add(self.person3) ah.add(self.person4) # Create a conference category = conference.CategoryManager().getById('0') self._conf = category.newConference(self._creator) self._conf.setTimezone('UTC') sd=datetime(2011, 06, 01, 10, 00, tzinfo=timezone("UTC")) ed=datetime(2011, 06, 05, 10, 00, tzinfo=timezone("UTC")) self._conf.setDates(sd,ed,) ch = ConferenceHolder() ch.add(self._conf) # Create contributions and add to the conference c1, c2 = Contribution(), Contribution() self.speaker1, self.speaker2 = ContributionParticipation(), ContributionParticipation() self.speaker1.setDataFromAvatar(self.person1) self.speaker2.setDataFromAvatar(self.person2) self._conf.addContribution(c2) self._conf.addContribution(c1) # Add speakers to contributions c1.addPrimaryAuthor(self.speaker1) c2.addPrimaryAuthor(self.speaker2) c1.addSpeaker(self.speaker1) c2.addSpeaker(self.speaker1) c2.addSpeaker(self.speaker2) self._conf.enableSessionSlots() # Create session and schedule the contributions s1 = Session() sd = datetime(2011, 06, 02, 12, 00, tzinfo=timezone("UTC")) ed = datetime(2011, 06, 02, 19, 00, tzinfo=timezone("UTC")) s1.setDates(sd, ed) slot1 = SessionSlot(s1) self._conf.addSession(s1) slot1.setValues({"sDate":sd}) s1.addSlot(slot1) s1.addContribution(c1) s1.addContribution(c2) slot1.getSchedule().addEntry(c1.getSchEntry()) slot1.getSchedule().addEntry(c2.getSchEntry()) self.createAndAcceptBooking() @with_context('database') def testRightsFiltering(self): ''' Test if the managing rights are respected. ''' manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId()) # Test that person3 has not access to webcasted talks requestType = CollaborationTools.getRequestTypeUserCanManage(self._conf, self.person3) contributions = manager.getContributionSpeakerByType(requestType) for cont in contributions: for spk in contributions[cont]: sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, spk.getId())) self.assert_(sw.getRequestType() == "recording" or sw.getRequestType() == "both") # Test that person4 has not access to recorded talks requestType = CollaborationTools.getRequestTypeUserCanManage(self._conf, self.person4) contributions = manager.getContributionSpeakerByType(requestType) for cont in contributions: for spk in contributions[cont]: sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, spk.getId())) self.assert_(sw.getRequestType() == "webcast" or sw.getRequestType() == "both") @with_context('database') @with_context('request') def testNOEMAILStatus(self): ''' Test if the status of the SpeakerWrapper is correctly updated to NOEMAIL.\n ''' manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId()) contributions = manager.getContributionSpeakerByType("both") ''' Check change to NOEMAIL status, when delete the email of a speaker (here: speaker1) Should change to this status only if the previous status is NOTSIGNED or PENDING ''' for cont in contributions: sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, self.speaker1.getId())) if sw: #remove the email from NOTSIGNED to NOEMAIL self.changeEmailService(cont, self.speaker1.getId(), "") self.assert_(sw.getStatus() == SpeakerStatusEnum.NOEMAIL) #reset email, then remove email from PENDING to NOEMAIL self.changeEmailService(cont, self.speaker1.getId(), "*****@*****.**") sw.setStatus(SpeakerStatusEnum.PENDING) self.changeEmailService(cont, self.speaker1.getId(), "") self.assert_(sw.getStatus() == SpeakerStatusEnum.NOEMAIL) #reset email, then remove email from SIGNED to SIGNED (no changes) self.changeEmailService(cont, self.speaker1.getId(), "*****@*****.**") sw.setStatus(SpeakerStatusEnum.SIGNED) self.changeEmailService(cont, self.speaker1.getId(), "") self.assert_(sw.getStatus() == SpeakerStatusEnum.SIGNED) #reset email, then remove email from FROMFILE to FROMFILE (no changes) self.changeEmailService(cont, self.speaker1.getId(), "*****@*****.**") sw.setStatus(SpeakerStatusEnum.FROMFILE) self.changeEmailService(cont, self.speaker1.getId(), "") self.assert_(sw.getStatus() == SpeakerStatusEnum.FROMFILE) #reset email, then remove email from REFUSED to REFUSED (no changes) self.changeEmailService(cont, self.speaker1.getId(), "*****@*****.**") sw.setStatus(SpeakerStatusEnum.REFUSED) self.changeEmailService(cont, self.speaker1.getId(), "") self.assert_(sw.getStatus() == SpeakerStatusEnum.REFUSED) @with_context('database') @with_context('request') def testPENDINGStatus(self): ''' Test if the status of the SpeakerWrapper is correctly updated to PENDING.\n ''' manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId()) contributions = manager.getContributionSpeakerByType("both") uniqueIdList = [] for cont in contributions: for spk in contributions[cont]: uniqueIdList.append("%s.%s"%(cont, spk.getId())) self.sendEmailService(uniqueIdList) for cont in contributions: for spk in contributions[cont]: sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, spk.getId())) self.assert_(sw.getStatus() == SpeakerStatusEnum.PENDING) @with_context('database') @with_context('request') def testSIGNEDStatus(self): ''' Test if the status of the SpeakerWrapper is correctly updated to SIGNED.\n ''' manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId()) contributions = manager.getContributionSpeakerByType("both") for cont in contributions: for spk in contributions[cont]: sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, spk.getId())) self.submitAgreementService(sw, 'accept') self.assert_(sw.getStatus() == SpeakerStatusEnum.SIGNED) @with_context('database') @with_context('request') def testREFUSEDStatus(self): ''' Test if the status of the SpeakerWrapper is correctly updated to REFUSED.\n ''' manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId()) contributions = manager.getContributionSpeakerByType("both") for cont in contributions: for spk in contributions[cont]: sw = manager.getSpeakerWrapperByUniqueId("%s.%s"%(cont, spk.getId())) self.submitAgreementService(sw, 'reject') self.assert_(sw.getStatus() == SpeakerStatusEnum.REFUSED) #========================================================================== # Here useful functions called during the tests def createAndAcceptBooking(self): manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId()) # Create a booking - Recording Request bookingParams = { 'otherComments': '', 'endDate': '', 'talkSelection': ['0'], 'numAttendees': '', 'talks': '', 'lectureStyle': 'lecturePresentation', 'numRemoteViewers': '', 'startDate': '', 'postingUrgency': 'withinWeek' } # Create a booking - Webcast Request bookingParamsWeb = { 'talkSelection': ['0'], 'talks': 'choose' } #Give rights to person3(recordingReq) and person4(webcastReq) (... _creator has both) manager.addPluginManager("RecordingRequest", self.person3) manager.addPluginManager("WebcastRequest", self.person4) if manager.canCreateBooking("RecordingRequest"): manager.createBooking("RecordingRequest", bookingParams) booking = manager.getSingleBooking("RecordingRequest") manager.acceptBooking(booking.getId()) if manager.canCreateBooking("WebcastRequest"): manager.createBooking("WebcastRequest", bookingParamsWeb) booking = manager.getSingleBooking("WebcastRequest") manager.acceptBooking(booking.getId()) def changeEmailService(self, contId, spkId, value): params = { 'value':value, 'confId':self._conf.getId(), 'contribId':contId, 'spkId': spkId } service = SetSpeakerEmailAddress(params) service._checkParams() service._getAnswer() def sendEmailService(self, uniqueId): fromField = { "name": "No-reply", "email": "*****@*****.**" } content = "This is a test {url} {talkTitle}..." params = { 'from': fromField, 'content': content, 'uniqueIdList': uniqueId, 'confId': self._conf.getId() } service = SendElectronicAgreement(params) service._checkParams() service._getAnswer() def submitAgreementService(self, sw, decision): params = { 'authKey':sw.getUniqueIdHash(), 'confId': self._conf.getId(), 'reason': 'because...' } if decision == 'accept': service = AcceptElectronicAgreement(params) else: service = RejectElectronicAgreement(params) service._checkParams() service._getAnswer()
def setUp(self): # create a context, for storing autoOps ContextManager.create() ContextManager.set('autoOps', []) a = Avatar() a.setId("creator") self._conf = ConferenceFacade(a) self._conf.setId('a') self._conf.setTimezone('UTC') self._conf.setDates( datetime(2009, 9, 21, 16, 0, 0, tzinfo=timezone("UTC")), datetime(2009, 9, 21, 19, 0, 0, tzinfo=timezone("UTC"))) self._slot1_sDate = datetime(2009, 9, 21, 17, 0, 0, tzinfo=timezone("UTC")) self._slot1_eDate = datetime(2009, 9, 21, 18, 0, 0, tzinfo=timezone("UTC")) self._slot2_sDate = datetime(2009, 9, 21, 18, 0, 0, tzinfo=timezone("UTC")) self._slot2_eDate = datetime(2009, 9, 21, 19, 0, 0, tzinfo=timezone("UTC")) self._slot2_laterDate = datetime(2009, 9, 21, 20, 0, 0, tzinfo=timezone("UTC")) self._session1 = Session() self._session1.setValues({ 'sDate': self._slot1_sDate, 'eDate': self._slot1_eDate }) self._conf.addSession(self._session1) self._slot1 = self._session1.getSlotById(0) self._slot2 = SessionSlot(self._session1) self._slot2.setValues({ 'sDate': self._slot2_sDate, 'eDate': self._slot2_eDate }) self._session1.addSlot(self._slot2)
class TestProtection(IndicoTestCase): _requires = ['db.Database', 'db.DummyUser'] def setUp(self): super(TestProtection, self).setUp() self._startDBReq() # Create a user ah = AvatarHolder() self._avatar = Avatar() self._avatar.setName("fake") self._avatar.setSurName("fake") self._avatar.setOrganisation("fake") self._avatar.setLang("en_GB") self._avatar.setEmail("*****@*****.**") self._avatar.setId("fake") ah.add(self._avatar) # Create a conference category = conference.CategoryManager().getById('0') self._conf = category.newConference(self._avatar) self._conf.setTimezone('UTC') sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC')) ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC')) self._conf.setDates(sd, ed) ch = ConferenceHolder() ch.add(self._conf) self._contrib1 = conference.Contribution() self._conf.addContribution(self._contrib1) self._session1 = conference.Session() self._conf.addSession(self._session1) self._session2 = conference.Session() self._conf.addSession(self._session2) self._contrib2 = conference.Contribution() self._session1.addContribution(self._contrib2) #Now we create the material (id=0) and attach it to the contrib self._material = conference.Material() self._contrib1.addMaterial(self._material) #Now we create a dummy file and attach it to the material filePath = os.path.join(os.getcwd(), "test.txt") fh = open(filePath, "w") fh.write("hola") fh.close() self._resource = conference.LocalFile() self._resource.setFilePath(filePath) self._resource.setFileName("test.txt") self._material.addResource(self._resource) self._stopDBReq() @with_context('database') def testOnlyPublic(self): self.assertEqual(self._conf.getAccessController().isFullyPublic(), True) self.assertEqual(self._contrib1.getAccessController().isFullyPublic(), True) self.assertEqual(self._contrib2.getAccessController().isFullyPublic(), True) self.assertEqual(self._session1.getAccessController().isFullyPublic(), True) self.assertEqual(self._session2.getAccessController().isFullyPublic(), True) self.assertEqual(self._material.getAccessController().isFullyPublic(), True) self.assertEqual(self._resource.getAccessController().isFullyPublic(), True) @with_context('database') def testOnlyPrivate(self): self._conf.setProtection(1) self._contrib1.setProtection(1) self._contrib2.setProtection(1) self._session1.setProtection(1) self._session2.setProtection(1) self._material.setProtection(1) self._resource.setProtection(1) self.assertEqual(self._conf.getAccessController().isFullyPrivate(), True) self.assertEqual(self._contrib1.getAccessController().isFullyPrivate(), True) self.assertEqual(self._contrib2.getAccessController().isFullyPrivate(), True) self.assertEqual(self._session1.getAccessController().isFullyPrivate(), True) self.assertEqual(self._session2.getAccessController().isFullyPrivate(), True) self.assertEqual(self._material.getAccessController().isFullyPrivate(), True) self.assertEqual(self._resource.getAccessController().isFullyPrivate(), True) @with_context('database') def testPrivateInPublic(self): self._contrib2.setProtection(1) self._session2.setProtection(1) self._resource.setProtection(1) self.assertEqual(self._session1.getAccessController().isFullyPublic(), False) self.assertEqual(self._conf.getAccessController().isFullyPublic(), False) self.assertEqual( self._session1.getAccessController().getProtectedChildren(), [self._contrib2]) self.assertEqual( self._contrib1.getAccessController().getProtectedChildren(), [self._resource]) self.assertEqual( self._material.getAccessController().getProtectedChildren(), [self._resource]) self.assertEqual( set(self._conf.getAccessController().getProtectedChildren()), set([self._contrib2, self._session2, self._resource])) self._contrib1.removeMaterial(self._material) self.assertEqual(self._contrib1.getAccessController().isFullyPublic(), True) self.assertEqual( self._material.getAccessController().getProtectedChildren(), []) self.assertEqual( set(self._conf.getAccessController().getProtectedChildren()), set([self._contrib2, self._session2])) self._conf.removeContribution(self._contrib2) self.assertEqual(self._session1.getAccessController().isFullyPublic(), True) self.assertEqual( self._session1.getAccessController().getProtectedChildren(), []) self.assertEqual( self._conf.getAccessController().getProtectedChildren(), [self._session2]) @with_context('database') def testPublicInPrivate(self): self._conf.setProtection(1) self._contrib2.setProtection(-1) self._session2.setProtection(-1) self._resource.setProtection(-1) self.assertEqual(self._session1.getAccessController().isFullyPrivate(), False) self.assertEqual(self._conf.getAccessController().isFullyPrivate(), False) self.assertEqual( self._session1.getAccessController().getPublicChildren(), [self._contrib2]) self.assertEqual( self._contrib1.getAccessController().getPublicChildren(), [self._resource]) self.assertEqual( self._material.getAccessController().getPublicChildren(), [self._resource]) self.assertEqual( set(self._conf.getAccessController().getPublicChildren()), set([self._contrib2, self._session2, self._resource])) self._contrib1.removeMaterial(self._material) self.assertEqual(self._contrib1.getAccessController().isFullyPrivate(), True) self.assertEqual( self._material.getAccessController().getPublicChildren(), []) self.assertEqual( set(self._conf.getAccessController().getPublicChildren()), set([self._contrib2, self._session2])) self._conf.removeContribution(self._contrib2) self.assertEqual(self._session1.getAccessController().isFullyPrivate(), True) self.assertEqual( self._session1.getAccessController().getPublicChildren(), []) self.assertEqual(self._conf.getAccessController().getPublicChildren(), [self._session2])
class TestAuthorIndex(unittest.TestCase): """Tests the author index """ def setUp(self): self._creator = Avatar() self._creator.setId("creator") self._categ = Category() self._conf = Conference(self._creator) self._conf.setId('a') self._conf.setTimezone('UTC') self._categ._addConference(self._conf) def testBasicIndexing(self): #Tests adding a contribution with some authors already on it c1 = Contribution() self._conf.addContribution(c1) auth1, auth2 = ContributionParticipation(), ContributionParticipation() auth1.setFirstName("hector") auth1.setFamilyName("sanchez sanmartin") auth1.setEmail("*****@*****.**") auth2.setFirstName("jose benito") auth2.setFamilyName("gonzalez lopez") auth2.setEmail("*****@*****.**") c1.addPrimaryAuthor(auth1) c1.addPrimaryAuthor(auth2) idx = self._conf.getAuthorIndex() self.assert_(auth1 in idx.getParticipations()[1]) self.assert_(len(idx.getParticipations()[1]) == 1) self.assert_(auth2 in idx.getParticipations()[0]) self.assert_(len(idx.getParticipations()[0]) == 1) c2 = Contribution() self._conf.addContribution(c2) auth3, auth4 = ContributionParticipation(), ContributionParticipation() auth3.setFirstName("hector") auth3.setFamilyName("sanchez sanmartin") auth3.setEmail("*****@*****.**") auth4.setFirstName("jose benito") auth4.setFamilyName("gonzalez lopez2") auth4.setEmail("*****@*****.**") c2.addPrimaryAuthor(auth3) c2.addPrimaryAuthor(auth4) #Tests removing a contribution from a conference updates the author # index correctly #self.assert_(auth3 in idx.getParticipations()[2]) #self.assert_(len(idx.getParticipations()[2])==2) #self.assert_(auth4 in idx.getParticipations()[1]) #self.assert_(len(idx.getParticipations()[1])==1) #self._conf.removeContribution(c2) #self.assert_(auth1 in idx.getParticipations()[1]) #self.assert_(len(idx.getParticipations()[1])==1) #self.assert_(auth2 in idx.getParticipations()[0]) #self.assert_(len(idx.getParticipations()[0])==1) #Tests adding additional authors to a contribution which is already # included in a conference updates the author index correctly #auth5=ContributionParticipation() #auth5.setFirstName("jean-yves") #auth5.setFamilyName("le meur") #auth5.setEmail("*****@*****.**") #c1.addPrimaryAuthor(auth5) #self.assert_(auth1 in idx.getParticipations()[2]) #self.assert_(len(idx.getParticipations()[2])==1) #self.assert_(auth2 in idx.getParticipations()[0]) #self.assert_(len(idx.getParticipations()[0])==1) #self.assert_(auth5 in idx.getParticipations()[1]) #self.assert_(len(idx.getParticipations()[1])==1) #Tests removing authors from a contribution which is already # included in a conference updates the author index correctly #c1.removePrimaryAuthor(auth5) #self.assert_(auth1 in idx.getParticipations()[1]) #self.assert_(len(idx.getParticipations()[1])==1) #self.assert_(auth2 in idx.getParticipations()[0]) #self.assert_(len(idx.getParticipations()[0])==1) def testChangesInAuthorData(self): #Checks that changes in the author data updates the author index # correctly c1 = Contribution() self._conf.addContribution(c1) auth1, auth2 = ContributionParticipation(), ContributionParticipation() auth1.setFirstName("zFN") auth1.setFamilyName("zSN") auth1.setEmail("zM") auth2.setFirstName("AFN") auth2.setFamilyName("ASN") auth2.setEmail("aM") c1.addPrimaryAuthor(auth1) c1.addPrimaryAuthor(auth2) idx = self._conf.getAuthorIndex() self.assert_(auth1 in idx.getParticipations()[1]) self.assert_(len(idx.getParticipations()[1]) == 1) self.assert_(auth2 in idx.getParticipations()[0]) self.assert_(len(idx.getParticipations()[0]) == 1) auth2.setFamilyName("ZZSN") self.assert_(auth1 in idx.getParticipations()[0]) self.assert_(len(idx.getParticipations()[0]) == 1) self.assert_(auth2 in idx.getParticipations()[1]) self.assert_(len(idx.getParticipations()[1]) == 1)
class TestAuthorSearch(unittest.TestCase): """Tests the author search """ def setUp(self): self._creator = Avatar() self._creator.setId("creator") self._conf = Conference(self._creator) self._conf.setTimezone('UTC') def testBasicSearch(self): c1 = Contribution() self._conf.addContribution(c1) auth1, auth2 = ContributionParticipation(), ContributionParticipation() auth1.setFamilyName("a") auth1.setFirstName("a") auth2.setFamilyName("b") auth2.setFirstName("b") c1.addPrimaryAuthor(auth1) c1.addPrimaryAuthor(auth2) self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1) self.assert_(len(self._conf.getContribsMatchingAuth("a")) == 1) self.assert_(c1 in self._conf.getContribsMatchingAuth("a")) self.assert_(c1 in self._conf.getContribsMatchingAuth("B")) self.assert_(len(self._conf.getContribsMatchingAuth("B")) == 1) auth3 = ContributionParticipation() auth3.setFamilyName("c") auth3.setFirstName("c") c1.addCoAuthor(auth3) self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1) self.assert_(len(self._conf.getContribsMatchingAuth("c")) == 0) def testAddAuthor(self): c1 = Contribution() self._conf.addContribution(c1) auth1, auth2 = ContributionParticipation(), ContributionParticipation() auth1.setFamilyName("a") auth1.setFirstName("a") auth2.setFamilyName("b") auth2.setFirstName("b") c1.addPrimaryAuthor(auth1) self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1) self.assert_(len(self._conf.getContribsMatchingAuth("a")) == 1) self.assert_(c1 in self._conf.getContribsMatchingAuth("a")) c1.addPrimaryAuthor(auth2) self.assert_(len(self._conf.getContribsMatchingAuth("b")) == 1) self.assert_(c1 in self._conf.getContribsMatchingAuth("b")) c1.removePrimaryAuthor(auth1) self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1) self.assert_(len(self._conf.getContribsMatchingAuth("a")) == 0) self.assert_(c1 not in self._conf.getContribsMatchingAuth("a")) self.assert_(len(self._conf.getContribsMatchingAuth("b")) == 1) self.assert_(c1 in self._conf.getContribsMatchingAuth("b")) def testWithdrawnContrib(self): #Withdrawn contributions authors must be searchable c1 = Contribution() self._conf.addContribution(c1) auth1 = ContributionParticipation() auth1.setFamilyName("a") auth1.setFirstName("a") c1.addPrimaryAuthor(auth1) c1.withdraw(self._creator, "ll") self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1) self.assert_(len(self._conf.getContribsMatchingAuth("a")) == 1) self.assert_(c1 in self._conf.getContribsMatchingAuth("a")) auth2 = ContributionParticipation() auth2.setFamilyName("b") auth2.setFirstName("b") c1.addPrimaryAuthor(auth2) #self._conf.getContribsMatchingAuth("b") #self.assert_(len(self._conf.getContribsMatchingAuth(""))==1) #self.assert_(len(self._conf.getContribsMatchingAuth("b"))==1) #self.assert_(c1 in self._conf.getContribsMatchingAuth("b")) def testAuthorsWithSameName(self): #one contribution could have 2 authors with the same name c1 = Contribution() self._conf.addContribution(c1) auth1 = ContributionParticipation() auth1.setFamilyName("a") auth1.setFirstName("a") c1.addPrimaryAuthor(auth1) auth2 = ContributionParticipation() auth2.setFamilyName("a") auth2.setFirstName("a") c1.addPrimaryAuthor(auth2) self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1) self.assert_(len(self._conf.getContribsMatchingAuth("a")) == 1) self.assert_(c1 in self._conf.getContribsMatchingAuth("a")) c1.removePrimaryAuthor(auth1) self.assert_(len(self._conf.getContribsMatchingAuth("")) == 1) self.assert_(len(self._conf.getContribsMatchingAuth("a")) == 1) self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
class TestElectronicAgreement(IndicoTestCase): _requires = [Collaboration_Feature] def setUp(self): ''' Create a conference, 0 Add 2 contributions to this conference, 0 and 1 To contribution 0 - Add 2 speakers, person1 and person2 To contribution 1 - Add 1 speaker, person1 ''' super(TestElectronicAgreement, self).setUp() self._startDBReq() self.falseSession = FalseSession() # Create few users self._creator = Avatar({"name": "God", "email": "*****@*****.**"}) self._creator.setId("creator") # Set God as admin AdminList.getInstance().getList().append(self._creator) self.person1 = Avatar({"name": "giuseppe", "email": "*****@*****.**"}) self.person1.setId("spk1") self.person2 = Avatar({"name": "gabriele", "email": "*****@*****.**"}) self.person1.setId("spk2") self.person3 = Avatar({"name": "lorenzo", "email": "*****@*****.**"}) self.person1.setId("spk3") self.person4 = Avatar({"name": "silvio", "email": "*****@*****.**"}) self.person1.setId("spk4") ah = AvatarHolder() ah.add(self.person1) ah.add(self.person2) ah.add(self.person3) ah.add(self.person4) # Create a conference category = conference.CategoryManager().getById('0') self._conf = category.newConference(self._creator) self._conf.setTimezone('UTC') sd = datetime(2011, 06, 01, 10, 00, tzinfo=timezone("UTC")) ed = datetime(2011, 06, 05, 10, 00, tzinfo=timezone("UTC")) self._conf.setDates( sd, ed, ) ch = ConferenceHolder() ch.add(self._conf) # Create contributions and add to the conference c1, c2 = Contribution(), Contribution() self.speaker1, self.speaker2 = ContributionParticipation( ), ContributionParticipation() self.speaker1.setDataFromAvatar(self.person1) self.speaker2.setDataFromAvatar(self.person2) self._conf.addContribution(c2) self._conf.addContribution(c1) # Add speakers to contributions c1.addPrimaryAuthor(self.speaker1) c2.addPrimaryAuthor(self.speaker2) c1.addSpeaker(self.speaker1) c2.addSpeaker(self.speaker1) c2.addSpeaker(self.speaker2) self._conf.enableSessionSlots() # Create session and schedule the contributions s1 = Session() sd = datetime(2011, 06, 02, 12, 00, tzinfo=timezone("UTC")) ed = datetime(2011, 06, 02, 19, 00, tzinfo=timezone("UTC")) s1.setDates(sd, ed) slot1 = SessionSlot(s1) self._conf.addSession(s1) slot1.setValues({"sDate": sd}) s1.addSlot(slot1) s1.addContribution(c1) s1.addContribution(c2) slot1.getSchedule().addEntry(c1.getSchEntry()) slot1.getSchedule().addEntry(c2.getSchEntry()) self.createAndAcceptBooking() self._stopDBReq() @with_context('database') def testRightsFiltering(self): ''' Test if the managing rights are respected. ''' manager = self._conf.getCSBookingManager() # Test that person3 has not access to webcasted talks requestType = CollaborationTools.getRequestTypeUserCanManage( self._conf, self.person3) contributions = manager.getContributionSpeakerByType(requestType) for cont in contributions: for spk in contributions[cont]: sw = manager.getSpeakerWrapperByUniqueId("%s.%s" % (cont, spk.getId())) self.assert_(sw.getRequestType() == "recording" or sw.getRequestType() == "both") # Test that person4 has not access to recorded talks requestType = CollaborationTools.getRequestTypeUserCanManage( self._conf, self.person4) contributions = manager.getContributionSpeakerByType(requestType) for cont in contributions: for spk in contributions[cont]: sw = manager.getSpeakerWrapperByUniqueId("%s.%s" % (cont, spk.getId())) self.assert_(sw.getRequestType() == "webcast" or sw.getRequestType() == "both") @with_context('database') def testNOEMAILStatus(self): ''' Test if the status of the SpeakerWrapper is correctly updated to NOEMAIL.\n ''' manager = self._conf.getCSBookingManager() contributions = manager.getContributionSpeakerByType("both") ''' Check change to NOEMAIL status, when delete the email of a speaker (here: speaker1) Should change to this status only if the previous status is NOTSIGNED or PENDING ''' for cont in contributions: sw = manager.getSpeakerWrapperByUniqueId( "%s.%s" % (cont, self.speaker1.getId())) if sw: #remove the email from NOTSIGNED to NOEMAIL self.changeEmailService(cont, self.speaker1.getId(), "") self.assert_(sw.getStatus() == SpeakerStatusEnum.NOEMAIL) #reset email, then remove email from PENDING to NOEMAIL self.changeEmailService(cont, self.speaker1.getId(), "*****@*****.**") sw.setStatus(SpeakerStatusEnum.PENDING) self.changeEmailService(cont, self.speaker1.getId(), "") self.assert_(sw.getStatus() == SpeakerStatusEnum.NOEMAIL) #reset email, then remove email from SIGNED to SIGNED (no changes) self.changeEmailService(cont, self.speaker1.getId(), "*****@*****.**") sw.setStatus(SpeakerStatusEnum.SIGNED) self.changeEmailService(cont, self.speaker1.getId(), "") self.assert_(sw.getStatus() == SpeakerStatusEnum.SIGNED) #reset email, then remove email from FROMFILE to FROMFILE (no changes) self.changeEmailService(cont, self.speaker1.getId(), "*****@*****.**") sw.setStatus(SpeakerStatusEnum.FROMFILE) self.changeEmailService(cont, self.speaker1.getId(), "") self.assert_(sw.getStatus() == SpeakerStatusEnum.FROMFILE) #reset email, then remove email from REFUSED to REFUSED (no changes) self.changeEmailService(cont, self.speaker1.getId(), "*****@*****.**") sw.setStatus(SpeakerStatusEnum.REFUSED) self.changeEmailService(cont, self.speaker1.getId(), "") self.assert_(sw.getStatus() == SpeakerStatusEnum.REFUSED) @with_context('database') def testPENDINGStatus(self): ''' Test if the status of the SpeakerWrapper is correctly updated to PENDING.\n ''' manager = self._conf.getCSBookingManager() contributions = manager.getContributionSpeakerByType("both") uniqueIdList = [] for cont in contributions: for spk in contributions[cont]: uniqueIdList.append("%s.%s" % (cont, spk.getId())) self.sendEmailService(uniqueIdList) for cont in contributions: for spk in contributions[cont]: sw = manager.getSpeakerWrapperByUniqueId("%s.%s" % (cont, spk.getId())) self.assert_(sw.getStatus() == SpeakerStatusEnum.PENDING) @with_context('database') def testSIGNEDStatus(self): ''' Test if the status of the SpeakerWrapper is correctly updated to SIGNED.\n ''' manager = self._conf.getCSBookingManager() contributions = manager.getContributionSpeakerByType("both") for cont in contributions: for spk in contributions[cont]: sw = manager.getSpeakerWrapperByUniqueId("%s.%s" % (cont, spk.getId())) self.submitAgreementService(sw, 'accept') self.assert_(sw.getStatus() == SpeakerStatusEnum.SIGNED) @with_context('database') def testREFUSEDStatus(self): ''' Test if the status of the SpeakerWrapper is correctly updated to REFUSED.\n ''' manager = self._conf.getCSBookingManager() contributions = manager.getContributionSpeakerByType("both") for cont in contributions: for spk in contributions[cont]: sw = manager.getSpeakerWrapperByUniqueId("%s.%s" % (cont, spk.getId())) self.submitAgreementService(sw, 'reject') self.assert_(sw.getStatus() == SpeakerStatusEnum.REFUSED) #========================================================================== # Here useful functions called during the tests def createAndAcceptBooking(self): manager = self._conf.getCSBookingManager() # Create a booking - Recording Request bookingParams = { 'otherComments': '', 'endDate': '', 'talkSelection': ['0'], 'numAttendees': '', 'talks': '', 'lectureStyle': 'lecturePresentation', 'numRemoteViewers': '', 'startDate': '', 'postingUrgency': 'withinWeek' } # Create a booking - Webcast Request bookingParamsWeb = {'talkSelection': ['0'], 'talks': 'choose'} #Give rights to person3(recordingReq) and person4(webcastReq) (... _creator has both) manager.addPluginManager("RecordingRequest", self.person3) manager.addPluginManager("WebcastRequest", self.person4) if manager.canCreateBooking("RecordingRequest"): manager.createBooking("RecordingRequest", bookingParams) booking = manager.getSingleBooking("RecordingRequest") manager.acceptBooking(booking.getId()) if manager.canCreateBooking("WebcastRequest"): manager.createBooking("WebcastRequest", bookingParamsWeb) booking = manager.getSingleBooking("WebcastRequest") manager.acceptBooking(booking.getId()) def changeEmailService(self, contId, spkId, value): params = { 'value': value, 'confId': self._conf.getId(), 'contribId': contId, 'spkId': spkId } service = SetSpeakerEmailAddress(params, self.falseSession, self.falseSession) #weird... service._checkParams() service._getAnswer() def sendEmailService(self, uniqueId): fromField = {"name": "No-reply", "email": "*****@*****.**"} content = "This is a test {url} {talkTitle}..." params = { 'from': fromField, 'content': content, 'uniqueIdList': uniqueId, 'confId': self._conf.getId() } service = SendElectronicAgreement(params, self.falseSession, self.falseSession) service._checkParams() service._getAnswer() def submitAgreementService(self, sw, decision): params = { 'authKey': sw.getUniqueIdHash(), 'confId': self._conf.getId(), 'reason': 'because...' } if decision == 'accept': service = AcceptElectronicAgreement(params, self.falseSession, self.falseSession) else: service = RejectElectronicAgreement(params, self.falseSession, self.falseSession) service._checkParams() service._getAnswer()
class TestWithdrawal(unittest.TestCase): """Tests different scenarios concerning the contribution withdrawal """ def setUp( self ): self._creator=Avatar() self._creator.setId("creator") self._conf=Conference(self._creator) self._conf.setTimezone('UTC') sd=datetime(2004, 01, 01, 10, 00, tzinfo=timezone("UTC")) ed=datetime(2004, 01, 05, 10, 00, tzinfo=timezone("UTC")) self._conf.setDates(sd,ed) def testBasicWithdrawal(self): c1,c2=Contribution(),Contribution() auth1,auth2=ContributionParticipation(),ContributionParticipation() self._conf.addContribution(c1) self._conf.addContribution(c2) auth1.setFirstName("a") auth1.setFamilyName("a") auth1.setEmail("a") auth2.setFirstName("b") auth2.setFamilyName("b") auth2.setEmail("b") c1.addPrimaryAuthor(auth1) c2.addPrimaryAuthor(auth2) s1=Session() sd=datetime(2004, 01, 01, 12, 00, tzinfo=timezone("UTC")) ed=datetime(2004, 01, 01, 19, 00, tzinfo=timezone("UTC")) s1.setDates(sd,ed) slot1=SessionSlot(s1) self._conf.addSession(s1) s1.addSlot(slot1) s1.addContribution(c1) s1.addContribution(c2) slot1.getSchedule().addEntry(c1.getSchEntry()) slot1.getSchedule().addEntry(c2.getSchEntry()) self.assert_(c1.isScheduled()) self.assert_(c2.isScheduled()) authIdx=self._conf.getAuthorIndex() self.assert_(auth1 in authIdx.getParticipations()[0]) self.assert_(auth2 in authIdx.getParticipations()[1]) c1.withdraw(self._creator,"test") self.assert_(not c1.isScheduled()) self.assert_(c2.isScheduled()) self.assert_(auth1 not in authIdx.getParticipations()[0]) self.assert_(auth2 in authIdx.getParticipations()[0]) auth1.setFirstName("aa") self.assert_(auth1 not in authIdx.getParticipations()[0]) self.assert_(auth2 in authIdx.getParticipations()[0]) auth3,auth4=ContributionParticipation(),ContributionParticipation() auth3.setFirstName("c") auth3.setFamilyName("c") auth3.setEmail("c") auth4.setFirstName("d") auth4.setFamilyName("d") auth4.setEmail("d") c1.addPrimaryAuthor(auth3) c2.addPrimaryAuthor(auth4) self.assert_(auth2 in authIdx.getParticipations()[0]) self.assert_(auth4 in authIdx.getParticipations()[1]) self.assertRaises(MaKaCError,slot1.getSchedule().addEntry,c1.getSchEntry())