Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
GroupUserFolder.tests.testPloneTools.TestGroupsTool Class Reference
Inheritance diagram for GroupUserFolder.tests.testPloneTools.TestGroupsTool:
Inheritance graph
[legend]
Collaboration diagram for GroupUserFolder.tests.testPloneTools.TestGroupsTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_isGroup
def test_getGroupById
def test_getGroupsByUserId
def test_listGroups
def test_listGroupIds
def test_listGroupNames
def test_searchForGroups
def afterSetUp
def test01Interfaces
def test02TestCaseCompletude
def test03ClassSecurityInfo

Public Attributes

 membership
 gruf
 groups
 prefix

Static Public Attributes

tuple klasses
tuple ignore_interfaces

Detailed Description

Definition at line 106 of file testPloneTools.py.


Member Function Documentation

Definition at line 67 of file testPloneTools.py.

00067 
00068     def afterSetUp(self):
00069         self.setRoles(['Manager'])
00070 
00071         # Basic assignements
00072         self.membership = self.portal.portal_membership
00073         self.gruf = self.portal.acl_users
00074         self.groups = self.portal.portal_groups
00075         self.prefix = self.gruf.getGroupPrefix()
00076         self.groups.groupWorkspacesCreationFlag = 0
00077 
00078         # Nuke Administators and Reviewers groups added in 2.1a2 migrations
00079         # (and any other migrated-in groups) to avoid test confusion
00080         self.groups.removeGroups(self.groups.listGroupIds())
00081 
00082         # Intial data
00083         self.groups.addGroup("grp")
00084         self.groups.addGroup("g1")
00085         self.groups.addGroup("g2")
00086         self.groups.addGroup("g3")
00087         self.groups.addGroup("g4")
00088         self.membership.addMember("u1", "secret", [], [])
00089         self.membership.addMember("u2", "secret", [], [])
00090         self.membership.addMember("u3", "secret", [], [])
00091         self.membership.addMember("u4", "secret", [], [])
00092         self.membership.addMember("u5", "secret", [], [])
00093         self.membership.addMember("u6", "secret", [], [])
00094         self.membership.addMember("u7", "secret", [], [])
00095         self.gruf.addMember("g1", "u2")
00096         self.gruf.addMember("g1", "u3")
00097         self.gruf.addMember("g1", "u4")
00098         self.gruf.addMember("g2", "u3")
00099         self.gruf.addMember("g2", "u4")
00100         self.gruf.addMember("g2", "u5")
00101         self.gruf.addMember("g3", "u4")
00102         self.gruf.addMember("g3", "u5")
00103         self.gruf.addMember("g3", "u6")
00104         self.gruf.addMember("g4", "u7")
00105 

Here is the call graph for this function:

Test that interfaces are okay

Definition at line 81 of file testInterface.py.

00081 
00082     def test01Interfaces(self,):
00083         """
00084         Test that interfaces are okay
00085         """
00086         # Check interface for each and every class
00087         ignore = getattr(self, "ignore_interfaces", [])
00088         for klass in self.klasses:
00089             intfs = getattr(klass, "__implements__", None)
00090             self.failUnless(intfs, "'%s' class doesn't implement an interface!" % (klass.__name__, ))
00091 
00092             # Flatten interfaces
00093             intfs = flattenList(intfs)
00094 
00095             # Check each and everyone
00096             for intf in intfs:
00097                 if intf in ignore:
00098                     continue
00099                 self.failUnless(
00100                     Verify.verifyClass(
00101                     intf,
00102                     klass,
00103                     ),
00104                     "'%s' class doesn't implement '%s' interface correctly." % (klass.__name__, intf.__name__, ),
00105                     )
00106 

Here is the call graph for this function:

Check that the test case is complete : each interface entry xxx must be associated
to a test_xxx method in the test class.

Definition at line 107 of file testInterface.py.

00107 
00108     def test02TestCaseCompletude(self,):
00109         """
00110         Check that the test case is complete : each interface entry xxx must be associated
00111         to a test_xxx method in the test class.
00112         """
00113         not_defined = []
00114         tests = dir(self)
00115         count = 0
00116         
00117         # Check interface for each and every class
00118         ignore = getattr(self, "ignore_interfaces", [])
00119         for klass in self.klasses:
00120             intfs = getattr(klass, "__implements__", None)
00121             self.failUnless(intfs, "'%s' class doesn't implement an interface!" % (klass.__name__, ))
00122 
00123             # Flatten interfaces
00124             intfs = flattenInterfaces(intfs)
00125 
00126             # Check each and every interface
00127             for intf in intfs:
00128                 if intf in ignore:
00129                     continue
00130                 for name in intf.names():
00131                     count += 1
00132                     if not "test_%s" % (name,) in tests:
00133                         not_defined.append("%s.%s" % (klass.__name__, name))
00134 
00135 
00136         # Raise in case some tests are missing
00137         if not_defined:
00138             raise RuntimeError, "%d (over %d) MISSING TESTS:\n%s do not have a test associated." % (
00139                 len(not_defined),
00140                 count,
00141                 string.join(not_defined, ", "),
00142                 )
00143         
        

Here is the call graph for this function:

This method tests that each and every method has a ClassSecurityInfo() declaration
XXX This doesn't walk through inheritance :(

Reimplemented in GroupUserFolder.tests.testUserAPI.TestUserFolderAPI.

Definition at line 144 of file testInterface.py.

00144 
00145     def test03ClassSecurityInfo(self):
00146         """
00147         This method tests that each and every method has a ClassSecurityInfo() declaration
00148         XXX This doesn't walk through inheritance :(
00149         """
00150         not_defined = []
00151         count = 0
00152         
00153         # Check interface for each and every class
00154         ignore = getattr(self, "ignore_interfaces", [])
00155         for klass in self.klasses:
00156             dict = dir(klass)
00157             intfs = getattr(klass, "__implements__", None)
00158             self.failUnless(intfs, "'%s' class doesn't implement an interface!" % (klass.__name__, ))
00159 
00160             # Flatten interfaces
00161             intfs = flattenInterfaces(intfs)
00162             
00163             # Now check the resulting class to see if the mapping was made
00164             # correctly. Note that this uses carnal knowledge of the internal
00165             # structures used to store this information!
00166             # Check each method of every interface
00167             for intf in intfs:
00168                 if intf in ignore:
00169                     continue
00170                 for name in intf.names():
00171                     count += 1
00172                     if not "%s__roles__" % (name,) in dict:
00173                         not_defined.append("%s.%s" % (klass.__name__, name))
00174 
00175         # Raise in case some tests are missing
00176         if not_defined:
00177             raise RuntimeError, "%d (over %d) MISSING SECURITY DECLARATIONS:\n%s do not have a security declaration associated." % (
00178                 len(not_defined),
00179                 count,
00180                 string.join(not_defined, ", "),
00181                 )
00182         

Here is the call graph for this function:

Returns the portal_groupdata-ish object for a group corresponding
to this id.

Definition at line 127 of file testPloneTools.py.

00127 
00128     def test_getGroupById(self, ):
00129         """Returns the portal_groupdata-ish object for a group corresponding
00130         to this id."""
00131         # Create a dummy group
00132         self.portal.portal_groups.addGroup("mygroup",)
00133 
00134         # Get group
00135         g = self.portal.portal_groups.getGroupById("mygroup")
00136         self.failUnless(g, "Emtpy or invalid group")

Returns a list of the groups the user corresponding to 'userid' belongs to.

Definition at line 137 of file testPloneTools.py.

00137 
00138     def test_getGroupsByUserId(self, ):
00139         """Returns a list of the groups the user corresponding to 'userid' belongs to."""
00140         grps = self.groups.getGroupsByUserId("u3")
00141         ids = map(lambda x: x.getGroupName(), grps)
00142         ids.sort()
00143         self.failUnless(ids == ["g1", "g2", ], "Invalid groups: '%s'" % (ids, ))

Definition at line 114 of file testPloneTools.py.

00114 
00115     def test_isGroup(self,):        
00116         g1 = self.groups.getGroupById("g1")
00117         g1.addMember("g2")
00118         ngroups = 0
00119         nusers = 0
00120         for u in g1.getGroupMembers():
00121             if self.groups.isGroup(u):
00122                 ngroups += 1
00123             else:
00124                 nusers += 1
00125         self.failUnlessEqual(ngroups, 1)
00126         self.failUnlessEqual(nusers, 3)

Returns a list of the available groups' ids.

Definition at line 150 of file testPloneTools.py.

00150 
00151     def test_listGroupIds(self, ):
00152         """Returns a list of the available groups' ids."""
00153         ids = self.groups.listGroupIds()
00154         ids.sort()
00155         self.failUnless(ids == ["g1", "g2", "g3", "g4", "grp", ], "Invalid groups list: '%s'" % (ids, ))

Returns a list of the available groups' ids.

Definition at line 156 of file testPloneTools.py.

00156 
00157     def test_listGroupNames(self, ):
00158         """Returns a list of the available groups' ids."""
00159         ids = self.groups.listGroupNames()
00160         ids.sort()
00161         self.failUnless(ids == ["g1", "g2", "g3", "g4", "grp", ], "Invalid groups list: '%s'" % (ids, ))

Returns a list of the available portal_groupdata-ish objects.

Definition at line 144 of file testPloneTools.py.

00144 
00145     def test_listGroups(self, ):
00146         """Returns a list of the available portal_groupdata-ish objects."""
00147         grps = self.groups.listGroups()
00148         ids = map(lambda x: x.getGroupName(), grps)
00149         self.failUnless(ids == ["g1", "g2", "g3", "g4", "grp", ], "Invalid groups list: '%s'" % (ids, ))

Return a list of groups meeting certain conditions. 

Definition at line 162 of file testPloneTools.py.

00162 
00163     def test_searchForGroups(self, ):    # maybe searchGroups()?
        """Return a list of groups meeting certain conditions. """

Member Data Documentation

Definition at line 73 of file testPloneTools.py.

Definition at line 72 of file testPloneTools.py.

Initial value:
(
        ActionProviderBase.__implements__,
    )

Definition at line 110 of file testPloneTools.py.

Initial value:
(        # tell which classes to check
        GroupsTool.GroupsTool,
        )

Definition at line 107 of file testPloneTools.py.

Definition at line 71 of file testPloneTools.py.

Definition at line 74 of file testPloneTools.py.


The documentation for this class was generated from the following file: