def setUpContent(self): login(self.portal, testing.SITE_ADMIN) self.ws = ws_helpers.create_workspace(self.workspaces, "test-workspace", title=u"Test Workspace") self.links = [] self.links_by_group = {} for i in range(1, 4): group_label = u"Group {0}".format(i) group_handle = add_group(self.ws, group_label) link_id = "link-{0}".format(i) link_title = u"Link {0}".format(i) self.ws.invokeFactory('RichLink', link_id, title=link_title, url="www.ixds.com", rmGroup=group_handle) self.links.append(self.ws[link_id]) self.links_by_group[group_handle] = self.ws[link_id] link_id = "link-without-group" self.ws.invokeFactory('RichLink', link_id, title="Link without Group", url="www.ixds.com") self.misc_link = self.ws[link_id] self.links.append(self.misc_link) self.links_by_group['Miscellaneous'] = self.misc_link add_group(self.ws, u"Empty Group") logout()
def setUpContent(self): pat.login(self.portal, testing.SITE_ADMIN) self.ws = ws_helpers.create_workspace( self.workspaces, "workspace", title=u"Workspace", description=u"A lengthy but interesting description", goals=u"Lorem ipsum. Add goals here.") ws_helpers.do_action_for(self.ws, 'publish-for-site-members-with-public-decription') self.links = [] for i in range(1, 4): group_label = u"Group {0}".format(i) group_handle = add_group(self.ws, group_label) link_id = "link-{0}".format(i) link_title = u"Link {0}".format(i) self.ws.invokeFactory('RichLink', link_id, title=link_title, url="www.ixds.com", rmGroup=group_handle) self.links.append(self.ws[link_id]) link_id = "link-without-group" self.ws.invokeFactory('RichLink', link_id, title="Link without Group", url="www.ixds.com") self.misc_link = self.ws[link_id] self.links.append(self.misc_link) add_group(self.ws, u"Empty Group") pat.logout()
def test_grouping(self): login(self.portal, testing.SITE_ADMIN) material_view = self.ws.restrictedTraverse("@@material") material_view.request['SESSION'] = {} material_view.update() expected_group_labels = [u'Miscellaneous'] group_labels = [x['label'] for x in material_view.groupedResults] self.assertEqual(group_labels, expected_group_labels) group_label = u"My Folder" group_handle = add_group(self.ws, group_label) self.link.rmGroup = group_handle self.link.reindexObject() catalog = getToolByName(self.portal, 'portal_catalog') expected_keys = [group_handle] keys = [x for x in catalog.Indexes.get("rmGroup", None)._index.keys()] self.assertEqual(keys, expected_keys) material_view.update() expected_group_labels = [group_label] group_labels = [x['label'] for x in material_view.groupedResults] self.assertEqual(group_labels, expected_group_labels)
def setUpContent(self): pat.login(self.portal, testing.SITE_ADMIN) self.project = helpers.create_project( self.workspaces, 'project', title=u"Project") self.project_admin = helpers.add_activated_student( self.people, u"Herbert Meier") self.project.addManager(self.project_admin.id) self.wss = [] for i in range(1, self.number_of_wss + 1): ws_id = "workspace_{0}".format(i) ws_title = u"Workspace {0}".format(i) ws = ws_helpers.create_workspace( self.workspaces, ws_id, title=ws_title) ws_member = helpers.add_activated_student( self.people, u"Workspace {0} Member".format(i)) ws.addMember(ws_member.id) ws_manager = helpers.add_activated_student( self.people, u"Workspace {0} Manager".format(i)) ws.addManager(ws_manager.id) self.project.add_workspace(ws) self.wss.append(ws) self.groups = [] self.links = [] def link_params(containers): for i, container in enumerate(containers): yield (i*2+1, container, False) yield (i*2+2, container, True) for i, parent, featured in link_params([self.project] + self.wss): label_xtras = u"({0}{1})".format( parent.title, featured and ", featured" or "") group_label = u"Group {0} {1}".format(i, label_xtras) group_handle = add_group(parent, group_label) self.groups.append((group_handle, group_label)) self.links.append( self.create_link( parent, " ".join(("Link", str(i), label_xtras)), rmGroup=group_handle, project_featured=featured)) pat.logout()
def test_grouping(self): login(self.driver, self.portal, username=testing.MANAGER, password=testing.PASSWORD) group_label = u"My Folder" group_handle = add_group(self.ws, group_label) self.misc_link.rmGroup = group_handle self.misc_link.reindexObject() open(self.driver, self.ws.absolute_url() + "/@@material") try: self.find_element(By.CSS_SELECTOR, ".file-list.grouped-by-rmGroup") except Exception as e: self.fail(e.msg) self.assert_group_with_items(group_label, [self.misc_link.title])