コード例 #1
0
    def test_shows_added_and_modified_objects(self, browser):
        self.grant('Manager')
        with freeze(datetime(2010, 12, 26, 10, 35)) as clock:
            folder = create(Builder('folder').titled('The Folder'))

            clock.forward(days=1)
            folder.reindexObject()  # updates modified date

            clock.forward(days=1)
            file_ = create(Builder('file').titled('The First File'))

            clock.forward(hours=1)
            browser.login().open(view='activity')
            self.assertEquals(2, len(activity.events()),
                              'Expected exactly two events')

            file_event, folder_event = activity.events()
            self.assertEquals(
                'Added an hour ago by test_user_1_',
                file_event.byline)
            self.assertEquals('The First File', file_event.title)
            self.assertEquals('{0}/view'.format(file_.absolute_url()),
                              file_event.url,
                              '/view should be appended for files')

            self.assertEquals(
                'Added day before by test_user_1_',
                folder_event.byline)
            self.assertEquals('The Folder', folder_event.title)
            self.assertEquals(folder.absolute_url(), folder_event.url)
コード例 #2
0
    def test_comment_is_shown(self, browser):
        """
        This test makes sure that the comment text of a comment activity
        is shown in the feed (cropped).
        """
        self.grant('Manager')
        self.enable_discussion_for_document()
        browser.login().visit(create(Builder('document').titled(u'The Page')))
        browser.fill({'Comment': '''Lorem ipsum dolor sit amet, consectetur
        adipiscing elit. Atque haec ita iustitiae propria sunt, ut sint
        virtutum reliquarum communia. Quod autem in homine praestantissimum
        atque optimum est, id deseruit. An vero displicuit ea, quae tributa
        est animi virtutibus tanta praestantia? Et quidem illud ipsum non
        nimium probo et tantum patior, philosophum loqui de cupiditatibus
        finiendis. Nulla profecto est, quin suam vim retineat a primo ad
        extremum.'''}).submit()

        browser.open(view='activity')
        self.assertEquals(
            [{'title': 'The Page',
              'url': 'http://nohost/plone/the-page',
              'byline': 'Comment added now by test_user_1_'},
             {'title': 'The Page',
              'url': 'http://nohost/plone/the-page',
              'byline': 'Added now by test_user_1_'}],
            activity.events_infos())

        self.assertEquals(
            'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
            ' Atque haec ita iustitiae propria ...',
            activity.events()[0].body_text)
コード例 #3
0
    def test_actor_not_available(self, browser):
        """
        This test makes sure that there won't be an error if the user who
        created an object is no longer available.
        """
        self.grant('Manager')
        # Become admin and create an unprivileged user.
        login(self.layer['portal'], TEST_USER_NAME)
        user = create(Builder('user').with_roles('Contributor'))
        logout()

        # Become the unprivileged and create an object.
        login(self.layer['portal'], user.getId())
        create(Builder('folder'))
        logout()

        # Become admin again and delete the unprivileged user.
        login(self.layer['portal'], TEST_USER_NAME)
        api.user.delete(user=user)
        transaction.commit()

        # Test.
        browser.login().open(view='activity')
        self.assertEquals(1, len(activity.events()),
                          'Expected exactly one event')
コード例 #4
0
    def test_local_activity_view_is_not_recursive(self, browser):
        folder = create(Builder('folder').titled('The Folder'))
        create(Builder('file').titled('The First File'))

        browser.login().open(folder, view='local-activity')
        self.assertEquals(
            ['The Folder'],
            map(attrgetter('title'), activity.events()))
コード例 #5
0
    def test_fetch_more_events(self, browser):
        self.grant('Manager')
        foo = create(Builder('page').titled('Foo'))
        bar = create(Builder('page').titled('Bar'))
        get_activity_soup().clear()

        with freeze(datetime(2010, 1, 2, 1)) as clock:
            def touch(obj):
                obj.setTitle(obj.Title() + '*')
                object_changed(obj)
                clock.forward(hours=1)

            touch(foo)
            touch(bar)
            touch(foo)
            touch(bar)
            touch(foo)
            touch(bar)

        transaction.commit()

        browser.login().open(view='activity?amount_of_events=2')
        events = activity.events()
        self.assertEquals(['Bar***', 'Foo***'],
                          map(attrgetter('title'), events))

        browser.open(view='activity?amount_of_events=2&last_activity={0}'.format(
                events[-1].activity_id))
        events = activity.events()
        self.assertEquals(['Bar**', 'Foo**'],
                          map(attrgetter('title'), events))

        browser.open(view='activity?amount_of_events=2&last_activity={0}'.format(
                events[-1].activity_id))
        events = activity.events()
        self.assertEquals(['Bar*', 'Foo*'],
                          map(attrgetter('title'), events))

        browser.open(view='activity?amount_of_events=2&last_activity={0}'.format(
                events[-1].activity_id))
        events = activity.events()
        self.assertEquals([],
                          map(attrgetter('title'), events))
コード例 #6
0
ファイル: test_tab.py プロジェクト: 4teamwork/ftw.activity
    def test_render_events(self, browser):
        with freeze(datetime(2010, 1, 2)) as clock:
            create(Builder('page').titled('One'))
            clock.backward(days=1)
            create(Builder('page').titled('Two'))
            clock.backward(days=1)
            create(Builder('page').titled('Three'))

        browser.login().open(view='tabbedview_view-activity')
        self.assertEquals(['One', 'Two', 'Three'],
                          map(attrgetter('title'), activity.events()))
コード例 #7
0
    def test_roles_changed_event(self, browser):
        self.grant('Manager')
        folder = create(Builder('folder').providing(IParticipationSupport))

        hugo = create(Builder('user').named(u'Hugo', u'B\xf6ss')
               .with_roles('Manager', on=folder))
        create(Builder('user').named(u'J\xf6hn', u'Doe')
               .with_roles('Editor', on=folder))

        browser.login(hugo).open(folder, view='participants')
        browser.click_on('change')
        # Only Editor and Contributor are selectable
        browser.fill({'Roles': ['Contributor']}).submit()

        self.maxDiff = None
        self.assertEquals(
            [
                {'action': 'added',
                 'actor': 'test_user_1_',
                 'path': '/plone/folder'},

                {'action': 'participation:role_changed',
                 'actor': 'hugo.boss',
                 'path': '/plone/folder',
                 'roles:userid': 'john.doe',
                 'roles:old': ('Editor',),
                 'roles:removed': ('Editor',),
                 'roles:new': ('Contributor',),
                 'roles:added': ('Contributor',),
                },
            ],

            get_soup_activities(('path',
                                 'action',
                                 'actor',
                                 'roles:userid',
                                 'roles:old',
                                 'roles:removed',
                                 'roles:new',
                                 'roles:added')))

        browser.open(folder, view='@@activity')
        newest_event = activity.events()[0]
        self.assertEquals(
            {'url': 'http://nohost/plone/folder',
             'byline': u'Role changed now by B\xf6ss Hugo',
             'title': ''},
            newest_event.infos())
        self.assertEquals(
            u'B\xf6ss Hugo has changed the role of Doe J\xf6hn'
            u' from Can edit to Can add.',
            newest_event.body_text)
コード例 #8
0
    def test_invitation_retracted_event(self, browser):
        self.grant('Manager')
        folder = create(Builder('folder').providing(IParticipationSupport))
        inviter = create(Builder('user').named(u'J\xf6hn', u'Doe'))
        invitation = Invitation(target=folder,
                                email='*****@*****.**',
                                inviter=inviter.getId(),
                                roles=['Reader'])
        transaction.commit()

        browser.login(inviter).open(view='invitations')
        browser.fill({'sent_invitations:list': invitation.iid})
        browser.click_on('Retract')

        self.maxDiff = None
        self.assertEquals(
            [
                {'action': 'added',
                 'actor': 'test_user_1_',
                 'path': '/plone/folder'},

                {'action': 'participation:invitation_retracted',
                 'actor': 'john.doe',
                 'path': '/plone/folder',
                 'invitation:inviter': 'john.doe',
                 'invitation:email': '*****@*****.**',
                 'invitation:roles': ('Reader',),
                },
            ],

            get_soup_activities(('path',
                                 'action',
                                 'actor',
                                 'invitation:inviter',
                                 'invitation:email',
                                 'invitation:roles',)))

        browser.open(folder, view='@@activity')
        newest_event = activity.events()[0]
        self.assertEquals(
            {'url': 'http://nohost/plone/folder',
             'byline': u'Invitation retracted now by Doe J\xf6hn',
             'title': ''},
            newest_event.infos())
        self.assertEquals(
            u'Doe J\xf6hn has retracted the invitation for [email protected].',
            newest_event.body_text)
コード例 #9
0
    def test_invitation_created_activity(self, browser):
        self.grant('Manager')
        user = create(Builder('user').named(u'J\xf6hn', u'Doe')
                      .with_roles('Manager'))
        folder = create(Builder('folder').providing(IParticipationSupport))
        browser.login(user).open(folder, view='invite_participants')
        browser.fill({'E-Mail Addresses': '*****@*****.**',
                      'Roles': ['Contributor'],
                      'Comment': u'Hi th\xf6re'})
        browser.find('Invite').click()

        self.maxDiff = None
        self.assertEquals(
            [
                {'action': 'added',
                 'actor': 'test_user_1_',
                 'path': '/plone/folder'},

                {'action': 'participation:invitation_created',
                 'actor': 'john.doe',
                 'path': '/plone/folder',
                 'invitation:inviter': u'john.doe',
                 'invitation:email': u'*****@*****.**',
                 'invitation:roles': (u'Contributor',),
                 'invitation:comment': u'Hi th\xf6re',
                },
            ],

            get_soup_activities(('path',
                                 'action',
                                 'actor',
                                 'invitation:inviter',
                                 'invitation:email',
                                 'invitation:roles',
                                 'invitation:comment')))

        browser.open(folder, view='@@activity')
        newest_event = activity.events()[0]
        self.assertEquals(
            {'url': 'http://nohost/plone/folder',
             'byline': u'Invitation created now by Doe J\xf6hn',
             'title': ''},
            newest_event.infos())
        self.assertEquals(
            u'Doe J\xf6hn has invited [email protected] as Can add.',
            newest_event.body_text)
コード例 #10
0
    def test_notification_sent_mail(self, browser):
        john = create(Builder('user').named('John', 'Doe'))
        hugo = create(Builder('user').named('Hugo', 'Boss'))
        file_ = create(Builder('file'))

        comment = u'Hall\xf6chen, schaut mal, das ist ne interssante Datei.'
        self.request['to_list'] = [john.getId()]
        self.request['cc_list'] = [hugo.getId()]
        notify(NotificationEvent(file_, comment))

        self.maxDiff = None
        self.assertEquals(
            [
                {'action': 'added',
                 'actor': 'test_user_1_',
                 'path': '/plone/file'},

                {'action': 'notification:email_sent',
                 'actor': 'test_user_1_',
                 'path': '/plone/file',
                 'notification:comment': comment,
                 'notification:to_userids': ('john.doe', ),
                 'notification:cc_userids': ('hugo.boss', ),
                },
            ],

            get_soup_activities(('path',
                                 'action',
                                 'actor',
                                 'notification:comment',
                                 'notification:to_userids',
                                 'notification:cc_userids')))
        transaction.commit()

        browser.open(file_, view='@@activity')
        newest_event = activity.events()[0]
        self.assertEquals(
            {'url': 'http://nohost/plone/file/view',
             'byline': 'Notification sent now by test_user_1_',
             'title': ''},
            newest_event.infos())
        self.assertEquals(
            u'TO: Doe John'
            u' CC: Boss Hugo'
            u' Comment: ' + comment,
            newest_event.body_text)
コード例 #11
0
    def test_removes_concurrent_changes_in_less_than_1_minute(self, browser):
        with freeze(datetime(2010, 1, 1, 2, 0)) as clock:
            page = create(Builder('page'))

            for _ in range(10):
                clock.forward(seconds=45)
                notify(ObjectEditedEvent(page))

            clock.forward(hours=1)
            notify(ObjectEditedEvent(page))
            transaction.commit()

            browser.login().open(view='activity')
            self.assertEquals(
                ['Changed now by test_user_1_',
                 'Changed an hour ago by test_user_1_',
                 'Added an hour ago by test_user_1_'],
                map(attrgetter('byline'), activity.events()))
コード例 #12
0
    def test_invitation_accepted_event(self, browser):
        self.grant('Manager')
        folder = create(Builder('folder').providing(IParticipationSupport))
        inviter = create(Builder('user').named(u'J\xf6hn', u'Doe'))
        user = create(Builder('user').named(u'Hugo', u'B\xf6ss'))
        Invitation(target=folder,
                   email=user.getProperty('email'),
                   inviter=inviter.getId(),
                   roles=['Reader'])
        transaction.commit()

        browser.login(user).open(view='invitations')
        browser.click_on("Yes, I'd like to participate")

        self.maxDiff = None
        self.assertEquals(
            [
                {'action': 'added',
                 'actor': 'test_user_1_',
                 'path': '/plone/folder'},

                {'action': 'participation:invitation_accepted',
                 'actor': 'hugo.boss',
                 'path': '/plone/folder',
                 'invitation:inviter': 'john.doe',
                 'invitation:email': '*****@*****.**',
                 'invitation:roles': ('Reader',),
                },
            ],

            get_soup_activities(('path',
                                 'action',
                                 'actor',
                                 'invitation:inviter',
                                 'invitation:email',
                                 'invitation:roles',)))

        browser.open(folder, view='@@activity')
        newest_event = activity.events()[0]
        self.assertEquals(
            {'url': 'http://nohost/plone/folder',
             'byline': u'Invitation accepted now by B\xf6ss Hugo',
             'title': ''},
            newest_event.infos())
コード例 #13
0
    def test_local_role_removed(self, browser):
        self.grant('Manager')
        folder = create(Builder('folder').providing(IParticipationSupport))
        hugo = create(Builder('user').named(u'Hugo', u'B\xf6ss')
               .with_roles('Manager', on=folder))
        user = create(Builder('user').named(u'J\xf6hn', u'Doe')
                      .with_roles('Editor', on=folder))

        browser.login(hugo).open(folder, view='participants')
        browser.fill({'userids:list': [user.getId()]}) \
               .find('Delete Participants').click()

        self.maxDiff = None
        self.assertEquals(
            [
                {'action': 'added',
                 'actor': 'test_user_1_',
                 'path': '/plone/folder'},

                {'action': 'participation:role_removed',
                 'actor': 'hugo.boss',
                 'path': '/plone/folder',
                 'roles:userid': 'john.doe',
                },
            ],

            get_soup_activities(('path',
                                 'action',
                                 'actor',
                                 'roles:userid')))

        browser.open(folder, view='@@activity')
        newest_event = activity.events()[0]
        self.assertEquals(
            {'url': 'http://nohost/plone/folder',
             'byline': u'Participant removed now by B\xf6ss Hugo',
             'title': ''},
            newest_event.infos())
        self.assertEquals(
            u'B\xf6ss Hugo has removed the participant Doe J\xf6hn.',
            newest_event.body_text)
コード例 #14
0
ファイル: test_tab.py プロジェクト: 4teamwork/ftw.activity
 def test_fetch_is_traversable(self, browser):
     create(Builder('page').titled('One'))
     browser.login().open(view='tabbedview_view-activity/fetch')
     self.assertEquals(['One'],
                       map(attrgetter('title'), activity.events()))
コード例 #15
0
 def test_raw_action_is_public(self, browser):
     self.grant('Manager')
     create(Builder('folder'))
     browser.login().open(view='activity')
     self.assertEquals(1, len(activity.events()),
                       'Expected exactly one event')