Exemple #1
0
    def test_readby_view_event(self):
        fireViewEvent(self.obj,'user1')
        assert 'user1' in get_readby(self.obj)

        fireViewEvent(self.obj,'user2')
        assert 'user2' in get_readby(self.obj)

        userids = ['user1',
                   'user2',]
        readby = list(get_readby(self.obj))
        readby.sort()
        self.assertEquals(userids,readby)
Exemple #2
0
 def test_get_and_set(self):
     username = PloneTestCase.default_user
     # login as simple user
     self.login(username)
     set_readby(self.obj)
     readby = get_readby(self.obj)
     self.failUnless(username in readby)
Exemple #3
0
 def test_readby_creator(self):
     username = PloneTestCase.default_user
     # login as simple user
     self.login(username)
     # create the object
     self.folder.invokeFactory('Document','document1')
     obj = self.folder['document1']
     # fire event
     notify(ObjectInitializedEvent(obj))
     creator = obj.Creator()
     readby = get_readby(obj)
     # creator's id must be into readby users
     self.failUnless(username in readby)
Exemple #4
0
 def test_set_unreadby(self):
     for x in range(1,5):
         fireViewEvent(self.obj,'user%s' % x)
     # check users
     assert 'user1' in get_readby(self.obj)
     assert 'user2' in get_readby(self.obj)
     # remove some users
     set_unreadby(self.obj, ['user1','user2'])
     assert 'user1' not in get_readby(self.obj)
     assert 'user2' not in get_readby(self.obj)
     # other users are still there
     assert 'user3' in get_readby(self.obj)
     assert 'user4' in get_readby(self.obj)
Exemple #5
0
 def get_readby(self):
     return get_readby(self.context)