Back to index

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

List of all members.

Public Member Functions

def test_wrapGroup
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 270 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:

Test group wrapping

Definition at line 278 of file testPloneTools.py.

00278 
00279     def test_wrapGroup(self,):
00280         """Test group wrapping"""
00281         g1 = self.groups.getGroupById("g1")
00282         self.failUnlessEqual(g1.__class__.__name__, "GroupData")
00283         self.failUnlessEqual(g1.getGroupName(), "g1")
00284         g1 = self.groups.getGroupById("group_g1")
00285         self.failUnlessEqual(g1.__class__.__name__, "GroupData")
00286         self.failUnlessEqual(g1.getGroupName(), "g1")
00287 


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 274 of file testPloneTools.py.

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

Definition at line 271 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: