示例#1
0
 def testBasicAddAndRemove( self ):
     session1,session2=Session(),Session()
     self._conf.addSession(session1)
     self.assert_(self._conf.getSessionById(session1.getId())==session1)
     self.assert_(session1 in self._conf.getSessionList())
     session1.delete()
     self.assert_(session1 not in self._conf.getSessionList())
     self.assert_(self._conf.getSessionById(session1.getId())==None)
示例#2
0
 def testSessions(self):
     s1=Session()
     self._conf.addSession(s1)
     sd=datetime(2004, 01, 01, 10, 00, tzinfo=timezone('UTC'))
     ed=datetime(2004, 01, 01, 16, 00, tzinfo=timezone('UTC'))
     s1.setDates(sd,ed)
     slot1=SessionSlot(s1)
     s1.addSlot(slot1)
     slot1.setStartDate(datetime(2004, 01, 01, 10, 00, tzinfo=timezone('UTC')))
示例#3
0
 def testSessionInclusion(self):
     session1,session2=Session(),Session()
     self._conf.addSession(session1)
     self._conf.addSession(session2)
     contrib1=Contribution()
     self._conf.addContribution(contrib1)
     contrib1.setTitle("debug")
     contrib1.setSession(session1)
     self.assert_(self._conf.hasContribution(contrib1))
     self.assert_(session1.hasContribution(contrib1))
     self.assert_(not session2.hasContribution(contrib1))
     contrib1.setSession(session2)
     self.assert_(self._conf.hasContribution(contrib1))
     self.assert_(not session1.hasContribution(contrib1))
     self.assert_(session2.hasContribution(contrib1))
     contrib1.setSession(None)
     self.assert_(self._conf.hasContribution(contrib1))
     self.assert_(not session1.hasContribution(contrib1))
     self.assert_(not session2.hasContribution(contrib1))
     contrib1.setSession(session1)
     self.assert_(self._conf.hasContribution(contrib1))
     self.assert_(session1.hasContribution(contrib1))
     self.assert_(not session2.hasContribution(contrib1))
     self._conf.removeContribution(contrib1)
     self.assert_(not self._conf.hasContribution(contrib1))
     self.assert_(not session1.hasContribution(contrib1))
     self.assert_(contrib1 not in session1.getContributionList())
     self.assert_(not session2.hasContribution(contrib1))
     self.assert_(contrib1 not in session2.getContributionList())
示例#4
0
 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())
示例#5
0
 def testSessions(self):
     s1 = Session()
     self._conf.addSession(s1)
     sd = datetime(2004, 01, 01, 10, 00, tzinfo=timezone('UTC'))
     ed = datetime(2004, 01, 01, 16, 00, tzinfo=timezone('UTC'))
     s1.setDates(sd, ed)
     slot1 = SessionSlot(s1)
     s1.addSlot(slot1)
     slot1.setStartDate(
         datetime(2004, 01, 01, 10, 00, tzinfo=timezone('UTC')))
示例#6
0
 def testContributionInclusion(self):
     session1,session2=Session(),Session()
     self._conf.addSession(session1)
     self._conf.addSession(session2)
     contrib1=Contribution()
     session1.addContribution(contrib1)
     self.assert_(self._conf.hasContribution(contrib1))
     self.assert_(session1.hasContribution(contrib1))
     self.assert_(not session2.hasContribution(contrib1))
     session1.removeContribution(contrib1)
     session2.addContribution(contrib1)
     self.assert_(self._conf.hasContribution(contrib1))
     self.assert_(not session1.hasContribution(contrib1))
     self.assert_(session2.hasContribution(contrib1))
     session2.removeContribution(contrib1)
     self.assert_(self._conf.hasContribution(contrib1))
     self.assert_(not session1.hasContribution(contrib1))
     self.assert_(not session2.hasContribution(contrib1))
示例#7
0
 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())
示例#8
0
 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)
示例#9
0
 def testMoveScheduledContribToSession(self):
     #tests that moving scheduled contributions at conference level into a 
     #   session works correctly: removes them from the conference schedule
     #   and includes them into the selected session
     self._conf.setDates(datetime(2004,1,1,9,0,tzinfo=timezone('UTC')),datetime(2004,1,5,10,0,tzinfo=timezone('UTC')))
     session1=Session()
     session1.setStartDate(datetime(2004,1,1,9,0,tzinfo=timezone('UTC')))
     session1.setDuration(hours=1,minutes=0)
     self._conf.addSession(session1)
     c1,c2=Contribution(),Contribution()
     self._conf.addContribution(c1)
     self._conf.addContribution(c2)
     self._conf.getSchedule().addEntry(c1.getSchEntry())
     self._conf.getSchedule().addEntry(c2.getSchEntry())
     self.assert_(c1.isScheduled())
     self.assert_(c2.isScheduled())
     session1.addContribution(c1)
     self.assert_(not c1.isScheduled())
     self.assert_(c2.isScheduled())
示例#10
0
    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)
示例#11
0
class TestPosterSchedule(unittest.TestCase):
    """Tests the schedule for posters like schedules management functions
    """

    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):
        #tests the basic adding of entries to a poster like timetable
        p1,p2,p3=Contribution(),Contribution(),Contribution()
        self._session.addContribution(p1)
        self._session.addContribution(p2)
        self._session.addContribution(p3)
        self._slot1.getSchedule().addEntry(p1.getSchEntry())
        self._slot1.getSchedule().addEntry(p2.getSchEntry())
        self._slot1.getSchedule().addEntry(p3.getSchEntry())
        self.assert_(p1.getDuration()==self._session.getContribDuration())
        self.assert_(p2.getDuration()==self._session.getContribDuration())
        self.assert_(p3.getDuration()==self._session.getContribDuration())
        self.assert_(p1.getStartDate()==self._slot1.getStartDate())
        self.assert_(p2.getStartDate()==self._slot1.getStartDate())
        self.assert_(p3.getStartDate()==self._slot1.getStartDate())
        self.assert_(p1.getSchEntry()==self._slot1.getSchedule().getEntries()[0])
        self.assert_(p2.getSchEntry()==self._slot1.getSchedule().getEntries()[1])
        self.assert_(p3.getSchEntry()==self._slot1.getSchedule().getEntries()[2])
        self._session.removeContribution(p2)
        self.assert_(p1.getDuration()==self._session.getContribDuration())
        self.assert_(p3.getDuration()==self._session.getContribDuration())
        self.assert_(p1.getStartDate()==self._slot1.getStartDate())
        self.assert_(p3.getStartDate()==self._slot1.getStartDate())
        self.assert_(p1.getSchEntry()==self._slot1.getSchedule().getEntries()[0])
        self.assert_(p3.getSchEntry()==self._slot1.getSchedule().getEntries()[1])

    def testStartDateNotChanging(self):
        #tests that changing the start date of an entry scheduled within a
        #   poster schedule has no effect
        p1=Contribution()
        self._session.addContribution(p1)
        self._slot1.getSchedule().addEntry(p1.getSchEntry())
        self.assert_(p1.getStartDate()==datetime(2004,1,1,11,0,tzinfo=timezone('UTC')))
        p1.setStartDate(datetime(2004,1,1,11,25,tzinfo=timezone('UTC')))
        self.assert_(p1.getStartDate()==datetime(2004,1,1,11,0,tzinfo=timezone('UTC')))

    def testChangeSlotStartDate(self):
        #checks that changing the start date of a slot changes all the entries'
        p1,p2=Contribution(),Contribution()
        self._session.addContribution(p1)
        self._session.addContribution(p2)
        self._slot1.getSchedule().addEntry(p1.getSchEntry())
        self._slot1.getSchedule().addEntry(p2.getSchEntry())
        self.assert_(p1.getStartDate()==datetime(2004,1,1,11,0,tzinfo=timezone('UTC')))
        self.assert_(p2.getStartDate()==datetime(2004,1,1,11,0,tzinfo=timezone('UTC')))
        self._slot1.setStartDate(datetime(2004,1,1,11,25,tzinfo=timezone('UTC')))
示例#12
0
 def testContributions(self):
     self._conf.setDates(datetime(2004,1,1,9,0,tzinfo=timezone('UTC')),datetime(2004,1,5,10,0,tzinfo=timezone('UTC')))
     from MaKaC.conference import Session,Contribution,SessionSlot
     self._conf.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
     self._conf.setEndDate(datetime(2005,1,1,10,0,tzinfo=timezone('UTC')))
     session1=Session()
     self._conf.addSession(session1)
     session1.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
     session1.setDuration(hours=5,minutes=0)
     slot1=SessionSlot(session1)
     slot1.setDuration(hours=2,minutes=0)
     session1.addSlot(slot1)
     slot2=SessionSlot(session1)
     slot2.setDuration(hours=2,minutes=0)
     session1.addSlot(slot2)
     self.assert_(slot2.getStartDate()==datetime(2004,1,1,12,0,tzinfo=timezone('UTC')))
     c1,c2,c3=Contribution(),Contribution(),Contribution()
     session1.addContribution(c1)
     session1.addContribution(c2)
     session1.addContribution(c3)
     c1.setDuration(0,30)
     c2.setDuration(0,30)
     c3.setDuration(0,30)
     from MaKaC.errors import MaKaCError
     #self.assertRaises(MaKaCError,slot1.getSchedule().addEntry,c1.getSchEntry())
     slot1.getSchedule().addEntry(c1.getSchEntry())
     slot1.getSchedule().addEntry(c2.getSchEntry())
     slot1.getSchedule().addEntry(c3.getSchEntry())
     self.assert_(c1.getStartDate()==datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
     self.assert_(c2.getStartDate()==datetime(2004,1,1,10,30,tzinfo=timezone('UTC')))
     self.assert_(c3.getStartDate()==datetime(2004,1,1,11,0,tzinfo=timezone('UTC')))
     #slot2.getSchedule().addEntry(c1.getSchEntry())
     #self.assert_(c1.getStartDate()==datetime(2004,1,1,12,0,tzinfo=timezone('UTC')))
     #self.assert_(c2.getStartDate()==datetime(2004,1,1,10,30,tzinfo=timezone('UTC')))
     #self.assert_(c3.getStartDate()==datetime(2004,1,1,11,0,tzinfo=timezone('UTC')))
     from MaKaC.schedule import BreakTimeSchEntry
     b1=BreakTimeSchEntry()
     slot1.getSchedule().addEntry(b1)
     self.assert_(b1 in slot1.getSchedule().getEntries())
示例#13
0
 def testSlots(self):
     self._conf.setDates(datetime(2004,1,1,9,0,tzinfo=timezone('UTC')),datetime(2004,1,5,10,0,tzinfo=timezone('UTC')))
     session1=Session()
     session1.setStartDate(datetime(2004,1,1,9,0,tzinfo=timezone('UTC')))
     session1.setDuration(hours=10,minutes=0)
     self._conf.addSession(session1)
     slot1=SessionSlot(session1)
     slot1.setDuration(hours=2,minutes=0)
     session1.addSlot(slot1)
     self.assert_(slot1.getSessionSchEntry() in session1.getSchedule().getEntries())
     self.assert_(slot1.getStartDate()==session1.getStartDate())
     self.assert_(slot1.getDuration().seconds==7200)
     slot2=SessionSlot(session1)
     slot2.setDuration(hours=2,minutes=0)
     session1.addSlot(slot2)
     self.assert_(slot1.getSessionSchEntry()==session1.getSchedule().getEntries()[0])
     self.assert_(slot1.getStartDate()==session1.getStartDate())
     self.assert_(slot1.getDuration().seconds==7200)
     self.assert_(slot2.getSessionSchEntry()==session1.getSchedule().getEntries()[1])
     self.assert_(slot2.getStartDate()==datetime(2004,1,1,11,0,tzinfo=timezone('UTC')))
     self.assert_(slot2.getDuration().seconds==7200)
     slot2.setStartDate(datetime(2004,1,1,15,0,tzinfo=timezone('UTC')))
     self.assert_(slot1.getSessionSchEntry()==session1.getSchedule().getEntries()[0])
     self.assert_(slot1.getStartDate()==session1.getStartDate())
     self.assert_(slot1.getDuration().seconds==7200)
     self.assert_(slot2.getSessionSchEntry()==session1.getSchedule().getEntries()[1])
     self.assert_(slot2.getStartDate()==datetime(2004,1,1,15,0,tzinfo=timezone('UTC')))
     self.assert_(slot2.getDuration().seconds==7200)
     slot1.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
     slot2.setStartDate(datetime(2004,1,1,9,0,tzinfo=timezone('UTC')))
     self.assert_(slot2.getStartDate()==datetime(2004,1,1,9,0,tzinfo=timezone('UTC')))
     #slot1.setStartDate(datetime(2004,1,1,11,0,tzinfo=timezone('UTC')))
     #slot2.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
     self.assert_(slot1.getSessionSchEntry()==session1.getSchedule().getEntries()[1])
     self.assert_(slot1.getDuration().seconds==7200)
     self.assert_(slot2.getSessionSchEntry()==session1.getSchedule().getEntries()[0])
     self.assert_(slot2.getStartDate()==datetime(2004,1,1,9,0,tzinfo=timezone('UTC')))
     self.assert_(slot2.getDuration().seconds==7200)
示例#14
0
class TestConferenceSchedule(unittest.TestCase):
    """Tests the basic schedule management functions
    """

    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)

    def tearDown(self):
        ContextManager.destroy()

    def _addContribToSession(self, session, sDate, duration):
        contrib = ContributionFacade()

        contrib.setParent(self._conf)

        session.addContribution(contrib)

        contrib.setDuration(duration,0)
        contrib.setStartDate(sDate)

        return contrib

    def _expandNewTest(self, sDate, duration, expSDate, expEDate):
        from MaKaC.schedule import ConferenceSchedule

        schedule = ConferenceSchedule(self._conf)

        contrib = self._addContribToSession(self._session1, sDate, duration)

        # scheduling
        self._slot2.getSchedule().addEntry(contrib.getSchEntry())

        self.assert_(self._slot2.getAdjustedStartDate() == expSDate)
        self.assert_(self._slot2.getAdjustedEndDate() == expEDate)


    def _expandResizeTest(self, sDate, sDuration, newDate, newDuration, expSDate, expEDate):
        from MaKaC.schedule import ConferenceSchedule

        schedule = ConferenceSchedule(self._conf)

        contrib = self._addContribToSession(self._session1, sDate, sDuration)

        # scheduling
        self._slot2.getSchedule().addEntry(contrib.getSchEntry())

        # changing time
        contrib.setStartDate(newDate)
        contrib.setDuration(dur=timedelta(hours=newDuration))

        self.assert_(self._slot2.getAdjustedStartDate() == expSDate)
        self.assert_(self._slot2.getAdjustedEndDate() == expEDate)

    def testNewContentExpandsSlotDown(self):
        """ A slot grows down due to new overflowing content """
        return self._expandNewTest(self._slot2_sDate,
                                   2,
                                   self._slot2_sDate,
                                   self._slot2_laterDate)

    def testNotifyNewContentExpandsSlotDown(self):
        """ When a slot grows down (new content), proper notification is triggered  """

        self.testNewContentExpandsSlotDown()

        ops = ContextManager.get('autoOps')

        self.assert_(len(ops) == 4)

        op1 = ops[0]
        op2 = ops[1]
        op3 = ops[0]
        op4 = ops[1]

##         self.assert_(type(op1[0]) == SessionSlot)
##         self.assert_(op1[1] == 'OWNER_END_DATE_EXTENDED')
##         self.assert_(type(op1[2]) == Session)
##         self.assert_(op1[3] == self._slot2_laterDate)

##         self.assert_(type(op2[0]) == SessionSlot)
##         self.assert_(op2[1] == 'OWNER_START_DATE_EXTENDED')
##         self.assert_(type(op2[2]) == SessionSlot)
##         self.assert_(op2[3] == self._slot1_sDate)

##         self.assert_(type(op3[0]) == SessionSlot)
##         self.assert_(op3[1] == 'OWNER_END_DATE_EXTENDED')
##         self.assert_(type(op3[2]) == Session)
##         self.assert_(op3[3] == self._slot2_laterDate)

##         self.assert_(type(op4[0]) == SessionSlot)
##         self.assert_(op4[1] == 'OWNER_END_DATE_EXTENDED')
##         self.assert_(type(op4[2]) == SessionSlot)
##         self.assert_(op4[3] == self._slot2_laterDate)

    def testNewContentExpandsSlotUp(self):
        """ A slot grows up due to new "underflowing" content """
        return self._expandNewTest(self._slot1_sDate,
                                   2,
                                   self._slot1_sDate,
                                   self._slot2_eDate)

    def testNotifyNewContentExpandsSlotUp(self):
        """ When a slot grows up (new content), proper notification is triggered  """

#        import rpdb2; rpdb2.start_embedded_debugger_interactive_password()

        self.testNewContentExpandsSlotUp()

        ops = ContextManager.get('autoOps')

        self.assert_(len(ops) == 3)

        op1 = ops[0]
        op2 = ops[1]

##         self.assert_(type(op1[0]) == SessionSlot)
##         self.assert_(op1[1] == 'OWNER_START_DATE_EXTENDED')
##         self.assert_(type(op1[2]) == SessionSlot)
##         self.assert_(op1[3] == self._slot1_sDate)
##         self.assert_(op1[4] == self._slot2_sDate)

##         # in an ideal world, this one should not be shown
##         self.assert_(type(op2[0]) == SessionSlot)
##         self.assert_(op2[1] == 'OWNER_END_DATE_EXTENDED')
##         self.assert_(type(op2[2]) == SessionSlot)
##         self.assert_(op2[3] == self._slot2_eDate)
##         self.assert_(op2[4] == self._slot2_sDate)

    def testNewContentExpandsSlotBoth(self):
        """ A slot grows up due to new content that both "underflows" and overflows """
        self._expandNewTest(datetime(2009, 9, 21, 17, 0, 0, tzinfo=timezone("UTC")),
                            3,
                            self._slot1_sDate,
                            self._slot2_laterDate)

    def testNewCrossingDoesNotCorruptSessionTime(self):
        """ Session start/end time does not get messed up by new overflowing content """
        from MaKaC.schedule import ConferenceSchedule

        schedule = ConferenceSchedule(self._conf)

        earlyDate = datetime(2009, 9, 21, 16, 0, 0, tzinfo=timezone("UTC"))

        contrib = self._addContribToSession(self._session1, earlyDate, 1)

        # scheduling
        self._slot2.getSchedule().addEntry(contrib.getSchEntry())

        self.assert_(self._session1.getAdjustedStartDate() == earlyDate)
        self.assert_(self._session1.getAdjustedEndDate() == self._slot2_eDate)

    def testResizeContentExpandsSlotDown(self):
        """ A slot grows down by resizing content to overflow"""
        self._expandResizeTest(self._slot2_sDate,
                         1,
                         datetime(2009, 9, 21, 18, 0, 0, tzinfo=timezone("UTC")),
                         2,
                         self._slot2_sDate,
                         datetime(2009, 9, 21, 20, 0, 0, tzinfo=timezone("UTC")))

    def testResizeContentExpandsSlotUp(self):
        """ A slot grows down by resizing content to "underflow" """
        self._expandNewTest(datetime(2009, 9, 21, 17, 0, 0, tzinfo=timezone("UTC")),
                         2,
                         datetime(2009, 9, 21, 17, 0, 0, tzinfo=timezone("UTC")),
                         self._slot2_eDate)

    def testResizeContentExpandsSlotBoth(self):
        """ A slot grows down by resizing content to bot "underflow" and overflow"""
        self._expandNewTest(datetime(2009, 9, 21, 17, 0, 0, tzinfo=timezone("UTC")),
                         3,
                         datetime(2009, 9, 21, 17, 0, 0, tzinfo=timezone("UTC")),
                         datetime(2009, 9, 21, 20, 0, 0, tzinfo=timezone("UTC")))

    def testResizeCrossingDoesNotCorruptSessionTime(self):
        """ Session start/end time does not get messed up by resizing content to overflow """
        from MaKaC.schedule import ConferenceSchedule

        schedule = ConferenceSchedule(self._conf)
        contrib = self._addContribToSession(self._session1, self._slot2_sDate, 1)

        # scheduling
        self._slot2.getSchedule().addEntry(contrib.getSchEntry())

        # changing time
        earlyDate = datetime(2009, 9, 21, 16, 0, 0, tzinfo=timezone("UTC"))
        contrib.setStartDate(earlyDate)

        self.assert_(self._session1.getAdjustedStartDate() == earlyDate)
        self.assert_(self._session1.getAdjustedEndDate() == self._slot2_eDate)
示例#15
0
    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)
示例#16
0
 def testSessions(self):
     s1 = Session()
     s1.setDates(datetime(2004, 01, 01, 10, 00, tzinfo=timezone('UTC')),
                 datetime(2004, 01, 01, 12, 00, tzinfo=timezone('UTC')))
示例#17
0
 def testDates(self):
     session1=Session()
     #self._conf.setStartDate(datetime(2004,1,1,8,0,tzinfo=timezone('UTC')))
     #self._conf.setEndDate(datetime(2005,1,1,8,0,tzinfo=timezone('UTC')))
     session1.setStartDate(datetime(2004,2,15,tzinfo=timezone('UTC')))
     self.assertRaises(MaKaCError,session1.setEndDate,datetime(2004,2,14,tzinfo=timezone('UTC')))
     session1.setEndDate(datetime(2004,2,16,tzinfo=timezone('UTC')))
     self.assert_(session1.getStartDate()==datetime(2004,2,15,tzinfo=timezone('UTC')))
     self.assert_(session1.getEndDate()==datetime(2004,2,16,tzinfo=timezone('UTC')))
     session1.setDates(datetime(2004,2,10,tzinfo=timezone('UTC')),datetime(2004,2,11,tzinfo=timezone('UTC')))
     self.assert_(session1.getStartDate()==datetime(2004,2,10,tzinfo=timezone('UTC')))
     self.assert_(session1.getEndDate()==datetime(2004,2,11,tzinfo=timezone('UTC')))
     session1.setDates(datetime(2004,2,15,tzinfo=timezone('UTC')),datetime(2004,2,16,tzinfo=timezone('UTC')))
     self.assert_(session1.getStartDate()==datetime(2004,2,15,tzinfo=timezone('UTC')))
     self.assert_(session1.getEndDate()==datetime(2004,2,16,tzinfo=timezone('UTC')))
     session1.setDates(datetime(2004,2,14,tzinfo=timezone('UTC')),datetime(2004,2,17,tzinfo=timezone('UTC')))
     self.assert_(session1.getStartDate()==datetime(2004,2,14,tzinfo=timezone('UTC')))
     self.assert_(session1.getEndDate()==datetime(2004,2,17,tzinfo=timezone('UTC')))
示例#18
0
 def testSessions(self):
     s1=Session()
     s1.setDates(datetime(2004, 01, 01, 10, 00, tzinfo=timezone('UTC')),datetime(2004, 01, 01, 12, 00, tzinfo=timezone('UTC')))
示例#19
0
        and end dates
    """
    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 testSessions(self):
        s1=Session()
        s1.setDates(datetime(2004, 01, 01, 10, 00, tzinfo=timezone('UTC')),datetime(2004, 01, 01, 12, 00, tzinfo=timezone('UTC')))
        self._conf.addSession(s1)
        s2=Session()
        s2.setDates(datetime(2004, 01, 01, 15, 00, tzinfo=timezone('UTC')),datetime(2004, 01, 01, 18, 00, tzinfo=timezone('UTC')))
        self._conf.addSession(s2)
        #checks that modifying conference dates which does not affect to 
        #   sessions is allowed
        self._conf.setStartDate(datetime(2004, 01, 01, 9, 00, tzinfo=timezone('UTC')))
        self._conf.setEndDate(datetime(2004, 01, 01, 19, 00, tzinfo=timezone('UTC')))
        #if a session is affected an error should be reported
        #self.assertRaises(MaKaCError,self._conf.setStartDate,datetime(2004, 01, 01, 10, 01, tzinfo=timezone('UTC')))
        #self.assertRaises(MaKaCError,self._conf.setEndDate,datetime(2004, 01, 01, 17, 00, tzinfo=timezone('UTC')))

    def testEntries(self):
        c1,c2=Contribution(),Contribution()
        b=BreakTimeSchEntry()
        self._conf.addContribution(c1)
        self._conf.addContribution(c2)
示例#20
0
 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):
        '''
        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()
示例#22
0
    """
    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 testSessions(self):
        s1 = Session()
        s1.setDates(datetime(2004, 01, 01, 10, 00, tzinfo=timezone('UTC')),
                    datetime(2004, 01, 01, 12, 00, tzinfo=timezone('UTC')))
        self._conf.addSession(s1)
        s2 = Session()
        s2.setDates(datetime(2004, 01, 01, 15, 00, tzinfo=timezone('UTC')),
                    datetime(2004, 01, 01, 18, 00, tzinfo=timezone('UTC')))
        self._conf.addSession(s2)
        #checks that modifying conference dates which does not affect to
        #   sessions is allowed
        self._conf.setStartDate(
            datetime(2004, 01, 01, 9, 00, tzinfo=timezone('UTC')))
        self._conf.setEndDate(
            datetime(2004, 01, 01, 19, 00, tzinfo=timezone('UTC')))
        #if a session is affected an error should be reported
        #self.assertRaises(MaKaCError,self._conf.setStartDate,datetime(2004, 01, 01, 10, 01, tzinfo=timezone('UTC')))
        #self.assertRaises(MaKaCError,self._conf.setEndDate,datetime(2004, 01, 01, 17, 00, tzinfo=timezone('UTC')))

    def testEntries(self):
        c1, c2 = Contribution(), Contribution()
示例#23
0
 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)
示例#24
0
 def testTypeSetUp(self):
     #test setting up the schedule type of a session works correctly
     self._conf.setDates(datetime(2004,1,1,9,0,tzinfo=timezone('UTC')),datetime(2004,1,5,10,0,tzinfo=timezone('UTC')))
     session=Session()
     session.setStartDate(datetime(2004,1,1,9,0,tzinfo=timezone('UTC')))
     session.setDuration(hours=10,minutes=0)
     self._conf.addSession(session)
     slot1=SessionSlot(session)
     session.addSlot(slot1)
     c1,c2,c3=Contribution(),Contribution(),Contribution()
     session.addContribution(c1)
     session.addContribution(c2)
     session.addContribution(c3)
     slot1.getSchedule().addEntry(c1.getSchEntry())
     slot1.getSchedule().addEntry(c2.getSchEntry())
     slot1.getSchedule().addEntry(c3.getSchEntry())
     self.assert_(c1.getSchEntry()==slot1.getSchedule().getEntries()[0])
     self.assert_(c2.getSchEntry()==slot1.getSchedule().getEntries()[1])
     self.assert_(c3.getSchEntry()==slot1.getSchedule().getEntries()[2])
     self.assert_(session.getScheduleType()=="standard")
     self.assert_(slot1.getSchedule().__class__==conference.SlotSchedule)
     session.setScheduleType("poster")
     self.assert_(session.getScheduleType()=="poster")
     self.assert_(slot1.getSchedule().__class__==conference.PosterSlotSchedule)
     self.assert_(len(slot1.getSchedule().getEntries())==0)
示例#25
0
class TestConferenceSchedule(unittest.TestCase):
    """Tests the basic schedule management functions
    """
    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)

    def tearDown(self):
        ContextManager.destroy()

    def _addContribToSession(self, session, sDate, duration):
        contrib = ContributionFacade()

        contrib.setParent(self._conf)

        session.addContribution(contrib)

        contrib.setDuration(duration, 0)
        contrib.setStartDate(sDate)

        return contrib

    def _expandNewTest(self, sDate, duration, expSDate, expEDate):
        from MaKaC.schedule import ConferenceSchedule

        schedule = ConferenceSchedule(self._conf)

        contrib = self._addContribToSession(self._session1, sDate, duration)

        # scheduling
        self._slot2.getSchedule().addEntry(contrib.getSchEntry())

        self.assert_(self._slot2.getAdjustedStartDate() == expSDate)
        self.assert_(self._slot2.getAdjustedEndDate() == expEDate)

    def _expandResizeTest(self, sDate, sDuration, newDate, newDuration,
                          expSDate, expEDate):
        from MaKaC.schedule import ConferenceSchedule

        schedule = ConferenceSchedule(self._conf)

        contrib = self._addContribToSession(self._session1, sDate, sDuration)

        # scheduling
        self._slot2.getSchedule().addEntry(contrib.getSchEntry())

        # changing time
        contrib.setStartDate(newDate)
        contrib.setDuration(dur=timedelta(hours=newDuration))

        self.assert_(self._slot2.getAdjustedStartDate() == expSDate)
        self.assert_(self._slot2.getAdjustedEndDate() == expEDate)

    def testNewContentExpandsSlotDown(self):
        """ A slot grows down due to new overflowing content """
        return self._expandNewTest(self._slot2_sDate, 2, self._slot2_sDate,
                                   self._slot2_laterDate)

    def testNotifyNewContentExpandsSlotDown(self):
        """ When a slot grows down (new content), proper notification is triggered  """

        self.testNewContentExpandsSlotDown()

        ops = ContextManager.get('autoOps')

        self.assert_(len(ops) == 4)

        op1 = ops[0]
        op2 = ops[1]
        op3 = ops[0]
        op4 = ops[1]

##         self.assert_(type(op1[0]) == SessionSlot)
##         self.assert_(op1[1] == 'OWNER_END_DATE_EXTENDED')
##         self.assert_(type(op1[2]) == Session)
##         self.assert_(op1[3] == self._slot2_laterDate)

##         self.assert_(type(op2[0]) == SessionSlot)
##         self.assert_(op2[1] == 'OWNER_START_DATE_EXTENDED')
##         self.assert_(type(op2[2]) == SessionSlot)
##         self.assert_(op2[3] == self._slot1_sDate)

##         self.assert_(type(op3[0]) == SessionSlot)
##         self.assert_(op3[1] == 'OWNER_END_DATE_EXTENDED')
##         self.assert_(type(op3[2]) == Session)
##         self.assert_(op3[3] == self._slot2_laterDate)

##         self.assert_(type(op4[0]) == SessionSlot)
##         self.assert_(op4[1] == 'OWNER_END_DATE_EXTENDED')
##         self.assert_(type(op4[2]) == SessionSlot)
##         self.assert_(op4[3] == self._slot2_laterDate)

    def testNewContentExpandsSlotUp(self):
        """ A slot grows up due to new "underflowing" content """
        return self._expandNewTest(self._slot1_sDate, 2, self._slot1_sDate,
                                   self._slot2_eDate)

    def testNotifyNewContentExpandsSlotUp(self):
        """ When a slot grows up (new content), proper notification is triggered  """

        #        import rpdb2; rpdb2.start_embedded_debugger_interactive_password()

        self.testNewContentExpandsSlotUp()

        ops = ContextManager.get('autoOps')

        self.assert_(len(ops) == 3)

        op1 = ops[0]
        op2 = ops[1]


##         self.assert_(type(op1[0]) == SessionSlot)
##         self.assert_(op1[1] == 'OWNER_START_DATE_EXTENDED')
##         self.assert_(type(op1[2]) == SessionSlot)
##         self.assert_(op1[3] == self._slot1_sDate)
##         self.assert_(op1[4] == self._slot2_sDate)

##         # in an ideal world, this one should not be shown
##         self.assert_(type(op2[0]) == SessionSlot)
##         self.assert_(op2[1] == 'OWNER_END_DATE_EXTENDED')
##         self.assert_(type(op2[2]) == SessionSlot)
##         self.assert_(op2[3] == self._slot2_eDate)
##         self.assert_(op2[4] == self._slot2_sDate)

    def testNewContentExpandsSlotBoth(self):
        """ A slot grows up due to new content that both "underflows" and overflows """
        self._expandNewTest(
            datetime(2009, 9, 21, 17, 0, 0, tzinfo=timezone("UTC")), 3,
            self._slot1_sDate, self._slot2_laterDate)

    def testNewCrossingDoesNotCorruptSessionTime(self):
        """ Session start/end time does not get messed up by new overflowing content """
        from MaKaC.schedule import ConferenceSchedule

        schedule = ConferenceSchedule(self._conf)

        earlyDate = datetime(2009, 9, 21, 16, 0, 0, tzinfo=timezone("UTC"))

        contrib = self._addContribToSession(self._session1, earlyDate, 1)

        # scheduling
        self._slot2.getSchedule().addEntry(contrib.getSchEntry())

        self.assert_(self._session1.getAdjustedStartDate() == earlyDate)
        self.assert_(self._session1.getAdjustedEndDate() == self._slot2_eDate)

    def testResizeContentExpandsSlotDown(self):
        """ A slot grows down by resizing content to overflow"""
        self._expandResizeTest(
            self._slot2_sDate, 1,
            datetime(2009, 9, 21, 18, 0, 0, tzinfo=timezone("UTC")), 2,
            self._slot2_sDate,
            datetime(2009, 9, 21, 20, 0, 0, tzinfo=timezone("UTC")))

    def testResizeContentExpandsSlotUp(self):
        """ A slot grows down by resizing content to "underflow" """
        self._expandNewTest(
            datetime(2009, 9, 21, 17, 0, 0, tzinfo=timezone("UTC")), 2,
            datetime(2009, 9, 21, 17, 0, 0, tzinfo=timezone("UTC")),
            self._slot2_eDate)

    def testResizeContentExpandsSlotBoth(self):
        """ A slot grows down by resizing content to bot "underflow" and overflow"""
        self._expandNewTest(
            datetime(2009, 9, 21, 17, 0, 0, tzinfo=timezone("UTC")), 3,
            datetime(2009, 9, 21, 17, 0, 0, tzinfo=timezone("UTC")),
            datetime(2009, 9, 21, 20, 0, 0, tzinfo=timezone("UTC")))

    def testResizeCrossingDoesNotCorruptSessionTime(self):
        """ Session start/end time does not get messed up by resizing content to overflow """
        from MaKaC.schedule import ConferenceSchedule

        schedule = ConferenceSchedule(self._conf)
        contrib = self._addContribToSession(self._session1, self._slot2_sDate,
                                            1)

        # scheduling
        self._slot2.getSchedule().addEntry(contrib.getSchEntry())

        # changing time
        earlyDate = datetime(2009, 9, 21, 16, 0, 0, tzinfo=timezone("UTC"))
        contrib.setStartDate(earlyDate)

        self.assert_(self._session1.getAdjustedStartDate() == earlyDate)
        self.assert_(self._session1.getAdjustedEndDate() == self._slot2_eDate)
示例#26
0
    def testSessionDates(self):
        from MaKaC.conference import Session,SessionSlot, Conference
        self._conf.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
        self._conf.setEndDate(datetime(2004,1,1,15,0,tzinfo=timezone('UTC')))
        session1=Session()
        session1.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
        session1.setEndDate(datetime(2004,1,1,15,0,tzinfo=timezone('UTC')))
        self._conf.addSession(session1)
        slot1=SessionSlot(session1)
        slot1.setDuration(hours=2,minutes=0)
        slot1.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
        session1.addSlot(slot1)
        # ------- SESSIONS -------
        # Session start date can not be bigger than the first slot start date
        self.assertRaises(MaKaCError, session1.setStartDate, datetime(2004,1,1,12,0,tzinfo=timezone('UTC')))
        # Session end date can not be prior than the last slot end date
        self.assertRaises(MaKaCError, session1.setEndDate, datetime(2004,1,1,11,0,tzinfo=timezone('UTC')))
        # Session duration must be bigger than zero.
        self.assertRaises(MaKaCError, session1.setDuration, 0,0)
        # Session start date can not be prior than the conference end date
        #self.assertRaises(MaKaCError, session1.setStartDate, datetime(2004,1,1,9,0,tzinfo=timezone('UTC')))
        # Session end date can not be bigger than the conference end date
        #self.assertRaises(MaKaCError, session1.setEndDate, datetime(2004,1,1,15,1,tzinfo=timezone('UTC')))
        # Session end date can not be bigger than the conference end date
        #self.assertRaises(MaKaCError, session1.setDuration, 6,1)

        # ------- SESSION SLOTS -------
        self._conf.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
        self._conf.setEndDate(datetime(2004,1,1,15,0,tzinfo=timezone('UTC')))
        session1.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
        session1.setEndDate(datetime(2004,1,1,15,0,tzinfo=timezone('UTC')))
        # Session slot duration must be bigger than zero.
        self.assertRaises(MaKaCError, slot1.setDuration, 0,0,0)
        # Forbid to create a slot alogn several days
        self._conf.setEndDate(datetime(2005,1,1,15,0,tzinfo=timezone('UTC')))
        self.assertRaises(MaKaCError, slot1.setDuration, 1,0,1)
        # Slot start date has to be between the session ones
        #self.assertRaises(MaKaCError, slot1.setStartDate, datetime(2004,1,1,9,59,tzinfo=timezone('UTC')))
        # Slot end date has to be between the session ones
        #self.assertRaises(MaKaCError, slot1.setDuration, 0,5,1)
        # If the duration is modified and any of the slot entries is affected then an excetpion is raised
        c1,c2,c3=Contribution(),Contribution(),Contribution()
        session1.addContribution(c1)
        session1.addContribution(c2)
        session1.addContribution(c3)
        c1.setDuration(0,30)
        c2.setDuration(0,30)
        c3.setDuration(0,30)
        from MaKaC.schedule import BreakTimeSchEntry
        b1=BreakTimeSchEntry()
        slot1.getSchedule().addEntry(c1.getSchEntry())
        slot1.getSchedule().addEntry(c2.getSchEntry())
        slot1.getSchedule().addEntry(c3.getSchEntry())
        self.assertRaises(MaKaCError, slot1.setDuration, 0,1,29)
        # Check that the duration of the entries do not overpass the slot duration
        slot1.setDuration(hours=1,minutes=30)
        #self.assertRaises(MaKaCError,c3.setDuration,0,31)
        c3.setDuration(0,30)
        slot1.setDuration(hours=2,minutes=0)
        slot1.getSchedule().addEntry(b1)
        #self.assertRaises(MaKaCError,b1.setDuration,0,31)
        #Check that entries start date is not less than owner start date
        #self.assertRaises(MaKaCError,c1.setStartDate,datetime(2004,1,1,9,59,tzinfo=timezone('UTC')))
        #self.assertRaises(MaKaCError,b1.setStartDate,datetime(2004,1,1,9,59,tzinfo=timezone('UTC')))
        #Move all the entries
        slot3=SessionSlot(session1)
        slot3.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
        slot3.setDuration(hours=3,minutes=0)        
        session1.addSlot(slot3)
        c4,c5=Contribution(),Contribution()
        session1.addContribution(c4)
        session1.addContribution(c5)
        c4.setTitle("campeon")
        c5.setTitle("campeonisimo")
        c4.setStartDate(datetime(2004,1,1,11,0,tzinfo=timezone('UTC')))
        c4.setDuration(0,30)
        c5.setDuration(0,30)        
        b2=BreakTimeSchEntry()
        b2.setDuration(0,30)
        b2.setTitle("breaaaaaaak")
        slot3.getSchedule().addEntry(c4.getSchEntry())
        slot3.getSchedule().addEntry(c5.getSchEntry())
        slot3.getSchedule().addEntry(b2)
        self.assert_(c4.getStartDate() == datetime(2004,1,1,11,0,tzinfo=timezone('UTC')))
        slot3.setStartDate(datetime(2004,1,1,11,0,tzinfo=timezone('UTC')))
        #self.assert_(c4.getStartDate() == datetime(2004,1,1,12,0,tzinfo=timezone('UTC')))
        

        # ------- CONFERENCE -------
        # Conference should not start after a entry
        #self.assertRaises(MaKaCError,self._conf.setStartDate,datetime(2004,1,1,10,1,tzinfo=timezone('UTC')))
        # Conference should not finish before a entry
        #self.assertRaises(MaKaCError,self._conf.setEndDate,datetime(2004,1,1,14,59,tzinfo=timezone('UTC')))
        # Conference should not start after a entry (TIME)
        #self.assertRaises(MaKaCError,self._conf.setStartTime,10,1)
        # Conference should not finish before a entry (TIME)
        self._conf.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
        self._conf.setEndDate(datetime(2005,1,1,18,0,tzinfo=timezone('UTC')))
        session2=Session()
        self._conf.addSession(session2)
        session2.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
        session2.setEndDate(datetime(2005,1,1,18,0,tzinfo=timezone('UTC')))
        slot2=SessionSlot(session2)
        slot2.setDuration(hours=2,minutes=0)
        slot2.setStartDate(datetime(2004,1,1,10,0,tzinfo=timezone('UTC')))
        session2.addSlot(slot2)
示例#27
0
    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()
示例#28
0
 def testSorting( self ):
     from MaKaC.conference import Contribution, ContributionType, Session, Track
     from MaKaC.webinterface.common import contribFilters
     from MaKaC.common.filters import SimpleFilter
     contrib1 = Contribution()
     contrib2 = Contribution()
     contrib3 = Contribution()
     self._conf.addContribution( contrib1 )
     self._conf.addContribution( contrib2 )
     self._conf.addContribution( contrib3 )
     # Sorting by ID
     sortingCrit = contribFilters.SortingCriteria( ["number"] )
     f = SimpleFilter( None, sortingCrit )
     contribList = f.apply(self._conf.getContributionList())
     self.assert_( len(contribList) == 3 )
     self.assert_( contribList[0] == contrib1 )
     self.assert_( contribList[1] == contrib2 )
     self.assert_( contribList[2] == contrib3 )
     #Sorting by Date
     contrib1.setStartDate(datetime(2004, 5, 1, 10, 30,tzinfo=timezone('UTC')))
     contrib2.setStartDate(datetime(2003, 5, 1, 10, 30,tzinfo=timezone('UTC')))
     sortingCrit = contribFilters.SortingCriteria( ["date"] )
     f = SimpleFilter( None, sortingCrit )
     contribList = f.apply(self._conf.getContributionList())
     self.assert_( len(contribList) == 3 )
     self.assert_( contribList[0] == contrib2 )
     self.assert_( contribList[1] == contrib1 )
     self.assert_( contribList[2] == contrib3 )
     # Sorting by Contribution Type
     contribType1 = ContributionType("oral presentation", "no description", self._conf)
     contribType2 = ContributionType("poster", "no description", self._conf)
     contrib1.setType(contribType1)
     contrib2.setType(contribType2)
     sortingCrit = contribFilters.SortingCriteria( ["type"] )
     f = SimpleFilter( None, sortingCrit )
     contribList = f.apply(self._conf.getContributionList())
     self.assert_( len(contribList) == 3 )
     self.assert_( contribList[0] == contrib1 )
     self.assert_( contribList[1] == contrib2 )
     self.assert_( contribList[2] == contrib3 )
     # Sorting by Session
     session1 = Session()
     self._conf.addSession(session1)
     session2 = Session()
     self._conf.addSession(session2)
     contrib1.setSession(session1)
     contrib2.setSession(session2)
     sortingCrit = contribFilters.SortingCriteria( ["session"] )
     f = SimpleFilter( None, sortingCrit )
     contribList = f.apply(self._conf.getContributionList())
     self.assert_( len(contribList) == 3 )
     self.assert_(contrib1 in contribList)
     self.assert_(contrib2 in contribList)
     self.assert_(contrib3 in contribList)
     # Sorting by Track
     track1 = Track()
     track1.setTitle("3")
     track1.setConference(self._conf)
     track2 = Track()
     track2.setTitle("1")
     track2.setConference(self._conf)
     contrib1.setTrack(track1)
     contrib2.setTrack(track2)
     sortingCrit = contribFilters.SortingCriteria( ["track"] )
     f = SimpleFilter( None, sortingCrit )
     contribList = f.apply(self._conf.getContributionList())
     self.assert_( len(contribList) == 3 )
     self.assert_( contribList[0] == contrib2 )
     self.assert_( contribList[1] == contrib1 )
     self.assert_( contribList[2] == contrib3 )