Back to index

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

List of all members.

Public Member Functions

def test_setProperties
def test_getProperty
def test_getProperties
def test_getGroupId
def test_getMemberId
def test_getGroupName
def test_getGroupMembers
def test_getAllGroupMembers
def test_getGroupMemberIds
def test_getAllGroupMemberIds
def test_addMember
def test_removeMember
def test_getGroup
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 288 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:

Definition at line 426 of file testPloneTools.py.

00426 
00427     def test_addMember(self,):
00428         g1 = self.groups.getGroupById("g1")
00429 
00430         # Valid user
00431         g1.addMember("u1")
00432         members = g1.getGroupMemberIds()
00433         members.sort()
00434         self.failUnlessEqual(
00435             members,
00436             ["u1", "u2", "u3", "u4", ]
00437             )
00438 
00439         # Invalid user
00440         self.failUnlessRaises(
00441             ValueError,
00442             g1.addMember,
00443             "bloubbloub",
00444             )

Definition at line 408 of file testPloneTools.py.

00408 
00409     def test_getAllGroupMemberIds(self,):
00410         g1 = self.groups.getGroupById("g1")
00411         members = g1.getAllGroupMemberIds()
00412         members.sort()
00413         self.failUnlessEqual(
00414             members,
00415             ["u2", "u3", "u4", ]
00416             )
00417 
00418         # Multiple level group members (ie. nested groups)
00419         g1.addMember("g2")
00420         members = g1.getAllGroupMemberIds()
00421         members.sort()
00422         self.failUnlessEqual(
00423             members,
00424             ["g2", "u2", "u3", "u4", "u5", ]
00425             )

Definition at line 371 of file testPloneTools.py.

00371 
00372     def test_getAllGroupMembers(self,):
00373         # Flat group members
00374         g1 = self.groups.getGroupById("g1")
00375         members = map(lambda x: x.getMemberId(), g1.getAllGroupMembers())
00376         members.sort()
00377         self.failUnlessEqual(
00378             members,
00379             ["u2", "u3", "u4", ]
00380             )
00381 
00382         # Multiple level group members (ie. nested groups)
00383         g1.addMember("g2")
00384         members = map(lambda x: x.getMemberId(), g1.getAllGroupMembers())
00385         members.sort()
00386         self.failUnlessEqual(
00387             members,
00388             ["g2", "u2", "u3", "u4", "u5", ]
00389             )

Definition at line 464 of file testPloneTools.py.

00464 
00465     def test_getGroup(self,):
00466         g1 = self.groups.getGroupById("g1")
00467         self.failUnlessEqual(
00468             g1.getGroup().__class__.__name__,
00469             "GRUFGroup",
00470             )
00471 

Definition at line 340 of file testPloneTools.py.

00340 
00341     def test_getGroupId(self,):
00342         g1 = self.groups.getGroupById("g1")
00343         self.failUnlessEqual(g1.getGroupId(), "g1")

Definition at line 390 of file testPloneTools.py.

00390 
00391     def test_getGroupMemberIds(self,):
00392         g1 = self.groups.getGroupById("g1")
00393         members = g1.getGroupMemberIds()
00394         members.sort()
00395         self.failUnlessEqual(
00396             members,
00397             ["u2", "u3", "u4", ]
00398             )
00399 
00400         # Multiple level group members (ie. nested groups)
00401         g1.addMember("g2")
00402         members = g1.getGroupMemberIds()
00403         members.sort()
00404         self.failUnlessEqual(
00405             members,
00406             ["g2", "u2", "u3", "u4", ]
00407             )

Definition at line 352 of file testPloneTools.py.

00352 
00353     def test_getGroupMembers(self,):
00354         # Flat group members
00355         g1 = self.groups.getGroupById("g1")
00356         members = map(lambda x: x.getMemberId(), g1.getGroupMembers())
00357         members.sort()
00358         self.failUnlessEqual(
00359             members,
00360             ["u2", "u3", "u4", ]
00361             )
00362 
00363         # Multiple level group members (ie. nested groups)
00364         g1.addMember("g2")
00365         members = map(lambda x: x.getMemberId(), g1.getGroupMembers())
00366         members.sort()
00367         self.failUnlessEqual(
00368             members,
00369             ["g2", "u2", "u3", "u4", ]
00370             )

Definition at line 348 of file testPloneTools.py.

00348 
00349     def test_getGroupName(self,):
00350         g1 = self.groups.getGroupById("g1")
00351         self.failUnlessEqual(g1.getGroupName(), "g1")

Definition at line 344 of file testPloneTools.py.

00344 
00345     def test_getMemberId(self,):
00346         g1 = self.groups.getGroupById("g1")
00347         self.failUnlessEqual(g1.getMemberId(), "g1")

Definition at line 324 of file testPloneTools.py.

00324 
00325     def test_getProperties(self,):
00326         g1 = self.groups.getGroupById("g1")
00327         self.failUnlessEqual(
00328             g1.getProperties(),
00329             {"email": "", "description": "", "title": ""},
00330             )
00331         g1.setProperties(email = "test@toto.com", description = "marih", title = "Hello")
00332         self.failUnlessEqual(
00333             g1.getProperties(),
00334             {
00335             "email": "test@toto.com",
00336             "description": "marih",
00337             "title": "Hello",
00338             },
00339             )

Definition at line 319 of file testPloneTools.py.

00319 
00320     def test_getProperty(self,):
00321         g1 = self.groups.getGroupById("g1")
00322         self.failUnlessEqual(g1.getProperty("name"), "g1")
00323 

Definition at line 445 of file testPloneTools.py.

00445 
00446     def test_removeMember(self,):
00447         g1 = self.groups.getGroupById("g1")
00448 
00449         # Valid user
00450         g1.removeMember("u2")
00451         members = g1.getGroupMemberIds()
00452         members.sort()
00453         self.failUnlessEqual(
00454             members,
00455             ["u3", "u4", ]
00456             )
00457 
00458         # Invalid user
00459         self.failUnlessRaises(
00460             ValueError,
00461             g1.removeMember,
00462             "bloubbloub",
00463             )

def GroupUserFolder.tests.testPloneTools.TestGroupData.test_setProperties (   self,
  properties = None,
  kw 
)
We set some properties on groups

Definition at line 296 of file testPloneTools.py.

00296 
00297     def test_setProperties(self, properties = None, **kw):
00298         """We set some properties on groups
00299         """
00300         g = self.groups.getGroupById("g1")
00301 
00302         # Regular property setting
00303         g.setProperties({
00304             "email": "test@toto.com",
00305             "description": "azer",
00306             })
00307         self.failUnlessEqual(g.getProperty("email"), "test@toto.com", )
00308         self.failUnlessEqual(g.getProperty("description"), "azer", )
00309         
00310         # Keyword property setting
00311         g.setProperties(email = "other@toto.com", description = "Bloub.")
00312         self.failUnlessEqual(g.getProperty("email"), "other@toto.com", )
00313         self.failIfEqual(g.getProperty("name"), "Bloub.")
00314 
00315         # The Hacky Touch
00316         g.setProperties(id = "INVALID")
00317         self.failIfEqual(g.getProperty("id"), "g1")
00318 


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

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

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