Example #1
0
 def setUp( self ):
     #Build an index
     from MaKaC.conference import TCIndex
     self._idx = TCIndex()
Example #2
0
class TestTCIndex( unittest.TestCase ):
    """Makes sure the track coordinators index is working properly as standalone
        component
    """

    def setUp( self ):
        #Build an index
        from MaKaC.conference import TCIndex
        self._idx = TCIndex()

    def tearDown( self ):
        pass

    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 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 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 )
    
    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 testUnindexingSeveralTracks( self ):
        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._idx.unindexCoordinator( av1, t1 )
        self.assert_( t1 not in self._idx.getTracks( av1 ) )
        self.assert_( t2 in self._idx.getTracks( av1 ) )