Exemplo n.º 1
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))
Exemplo n.º 2
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')))