def testIGroupAdapter(self): """Verify all methods of the IGroup adapter to the Classification content type """ from Products.membrane.interfaces import IGroup from Products.CMFCore.utils import getToolByName wf = getToolByName(self.classification, 'portal_workflow') #adapt to IGroup g = IGroup(self.classification) #group title is the content object title self.classification.setTitle('New Title') self.failUnless( g.Title() == 'New Title', "IGroup.getTitle is not finding the correct title:\nexpected: %s\nfound: %s" % (self.classification.Title(), g.Title())) # group id is set on content object, uniqueness is enforced elsewhere self.failUnless( g.getGroupId() == self.classification.getId(), "getGroupId returning incorrect value:\nExpected: %s\nReceived: %s" % (self.classification.getId(), g.getGroupId())) #members are obtained correctly, regardless of how the classification was added #added from person object self.person.setClassifications((self.classification, )) self.person2.setClassifications((self.classification, )) members = list(g.getGroupMembers()) members.sort() self.failUnless(members == ['abc123', 'def456'], "incorrect member list: %s" % members) #clear the list self.classification.setPeople(()) self.failIf( self.classification.getPeople(), "there are still people listed in this classification: %s" % self.classification.getPeople()) #added from classification object self.classification.setPeople((self.person, self.person2)) members = list(g.getGroupMembers()) members.sort() self.failUnless(members == ['abc123', 'def456'], "incorrect member list: %s" % members) #deactivate group and verify emptiness wf.doActionFor(self.classification, 'deactivate') members = list(g.getGroupMembers()) members.sort() self.failUnless( members == [], "deactivated group has non-empty member list: %s" % members)
def testIGroupAdapter(self): """Verify all methods of the IGroup adapter to the FacultyStaffDirectory content type """ from Products.membrane.interfaces import IGroup from Products.CMFCore.utils import getToolByName fsd = self.getPopulatedDirectory() wf = getToolByName(fsd, 'portal_workflow') #adapt to IGroup g = IGroup(fsd) #group title is the content object title fsd.setTitle("My FSD") self.failUnless(g.Title() == "My FSD") #roles are set on the object, but only available when object is published fsd.setRoles(('Reviewer', )) # at first, object is 'visible', but not published, roles should be empty self.failIf( 'Reviewer' in g.getRoles(), "roles are active, but content unpublished\nRoles: %s\nReviewState: %s" % (g.getRoles(), wf.getInfoFor(fsd, 'review_state'))) #publish object wf.doActionFor(fsd, 'publish') # now check again, role should be there self.failUnless( 'Reviewer' in g.getRoles(), "Roles not active, but content published\nRoles: %s\nReviewState: %s" % (g.getRoles(), wf.getInfoFor(fsd, 'review_state'))) # group id is set on content object, uniqueness is enforced elsewhere self.failUnless( g.getGroupId() == fsd.getId(), "getGroupId returning incorrect value:\nExpected: %s\nReceived: %s" % (fsd.getId(), g.getGroupId())) #members are obtained correctly self.person1 = self.getPerson(id='abc123', firstName="Test", lastName="Person") self.person2 = self.getPerson(id='def456', firstName="Testy", lastName="Persons") self.person3 = self.getPerson(id='ghi789', firstName="Tester", lastName="Personage") members = list(g.getGroupMembers()) members.sort() self.failUnless(members == ['abc123', 'def456', 'ghi789'], "incorrect member list: %s" % members)