def test_grantAccess( self ):
     user = MockUser( )
     component = Component( 'random' )
     self.assertEquals( [], user.grantedPermissions )
     component.grantAccessFor( user )
     self.assertEquals([ 'component_random' ], user.grantedPermissions )
     self.assertTrue( component.canBeAccessedBy( user ))
    def test_canAccess( self ):
        user1 = MockUser( 'component_random' )
        user2 = MockUser( )
        component = Component( 'random' )
        self.assertTrue( component.canBeAccessedBy( user1 ))
        self.assertEquals([ 'component_random' ], user1.requestedPermission )

        self.assertFalse( component.canBeAccessedBy( user2 ))
        self.assertEquals([ 'component_random' ], user2.requestedPermission )
 def test_id( self ):
     component = Component( 'MyComponent' )
     self.assertEquals( 'MyComponent', component.id() )
 def test_removeAccess( self ):
     user = MockUser()
     component = Component( 'random' )
     component.grantAccessFor( user )
     component.forbidAccessFor( user )
     self.assertFalse( component.canBeAccessedBy( user ))