Esempio n. 1
0
 def test_my_workspaces(self):
     ws_before = my_workspaces(self.portal.workspaces)
     api.content.create(self.portal.workspaces,
                        'ploneintranet.workspace.workspacefolder',
                        'example-workspace')
     ws_after = my_workspaces(self.portal.workspaces)
     self.assertEqual(len(ws_after) - len(ws_before), 1)
 def test_my_workspaces(self):
     ws_before = my_workspaces(self.portal.workspaces)
     api.content.create(
         self.portal.workspaces,
         'ploneintranet.workspace.workspacefolder',
         'example-workspace')
     ws_after = my_workspaces(self.portal.workspaces)
     self.assertEqual(len(ws_after) - len(ws_before), 1)
Esempio n. 3
0
    def test_my_workspaces_limit(self):
        ''' This will test that with a limit parameter we slice the results

        '''
        # create dummy stuff
        workspace_container = api.content.create(
            self.portal,
            'ploneintranet.workspace.workspacecontainer',
            'workspace-container-sorting',
            title='Workspace container sorting')
        api.content.create(
            workspace_container,
            'ploneintranet.workspace.workspacefolder',
            'sort1',
            title="Sortable 1",
        )
        api.content.create(
            workspace_container,
            'ploneintranet.workspace.workspacefolder',
            'sort2',
            title="Sortable 2",
        )
        # Check default query
        response = my_workspaces(workspace_container, )
        self.assertListEqual(
            [item['title'] for item in response],
            ['Sortable 1', 'Sortable 2'],
        )

        # Check with a broken limit
        response = my_workspaces(
            workspace_container,
            request={'limit': 'broken limit'},
        )
        self.assertListEqual(
            [item['title'] for item in response],
            ['Sortable 1', 'Sortable 2'],
        )

        # Check with a broken limit
        response = my_workspaces(
            workspace_container,
            request={'limit': '1'},
        )
        self.assertListEqual(
            [item['title'] for item in response],
            ['Sortable 1'],
        )

        # Get rid of testing content
        api.content.delete(workspace_container)
Esempio n. 4
0
 def workspaces(self):
     ''' The list of my workspaces
     '''
     include_activities = self.get_selected_sort_option() == 'activity'
     return map(
         AdaptableWSDict,
         my_workspaces(
             self.context,
             self.request,
             include_activities=include_activities,
         ))
 def workspaces(self):
     ''' The list of my workspaces
     '''
     return my_workspaces(self.context)
Esempio n. 6
0
    def test_my_workspaces_sorting(self):
        ''' This will test that:

        - sorting by default is by sortable_title
        - it can be by modification date (reversed)
        - it can be by activity date (reversed)
        - it can take any value and will not fail
        '''
        # create dummy stuff
        workspace_container = api.content.create(
            self.portal,
            'ploneintranet.workspace.workspacecontainer',
            'workspace-container-sorting',
            title='Workspace container sorting')
        obj1 = api.content.create(
            workspace_container,
            'ploneintranet.workspace.workspacefolder',
            'sort1',
            title="Sortable 1",
        )
        obj1.modification_date = datetime.strptime('2015/01/01', '%Y/%m/%d')
        obj1.reindexObject(idxs=['modified'])
        obj2 = api.content.create(
            workspace_container,
            'ploneintranet.workspace.workspacefolder',
            'sort2',
            title="Sortable 2",
        )
        obj2.modification_date = datetime.strptime('2016/01/01', '%Y/%m/%d')
        obj2.reindexObject(idxs=['modified'])
        obj3 = api.content.create(
            workspace_container,
            'ploneintranet.workspace.workspacefolder',
            'sort3',
            title="Sortable 3",
        )
        obj3.modification_date = datetime.strptime('2015/07/01', '%Y/%m/%d')
        obj3.reindexObject(idxs=['modified'])

        # Create some status updates
        pi_api.microblog.statusupdate.create('test 3', microblog_context=obj3)

        # Check default query
        response = my_workspaces(workspace_container, )
        self.assertListEqual(
            [item['title'] for item in response],
            ['Sortable 1', 'Sortable 2', 'Sortable 3'],
        )

        # Check sort=alphabet
        response = my_workspaces(
            workspace_container,
            request={'sort': 'alphabet'},
        )
        self.assertListEqual(
            [item['title'] for item in response],
            ['Sortable 1', 'Sortable 2', 'Sortable 3'],
        )

        # Check sort=newest
        response = my_workspaces(
            workspace_container,
            request={'sort': 'newest'},
        )
        self.assertListEqual(
            [item['title'] for item in response],
            ['Sortable 2', 'Sortable 3', 'Sortable 1'],
        )

        # Check sort=activity
        response = my_workspaces(
            workspace_container,
            request={'sort': 'activity'},
        )
        self.assertEqual(response[0]['title'], 'Sortable 3')

        # Get rid of testing content
        api.content.delete(workspace_container)