|
22 | 22 |
|
23 | 23 |
|
24 | 24 | def login(portal, userName): |
25 | | - """Log in as the given user in the given Plone site""" |
| 25 | + """Log in as the named user in the given Plone site. |
| 26 | +
|
| 27 | + Subsequent operations run as this user until :func:`logout` is called |
| 28 | + or the test tears down. |
| 29 | +
|
| 30 | + :param portal: the Plone site to log in to. |
| 31 | + :param userName: the login name of the user to become, for example |
| 32 | + :data:`TEST_USER_NAME`. This is the login name, not the user id. |
| 33 | + """ |
26 | 34 |
|
27 | 35 | zope.login(portal["acl_users"], userName) |
28 | 36 |
|
29 | 37 |
|
30 | 38 | def logout(): |
31 | | - """Log out, i.e. become anonymous""" |
| 39 | + """Log out, so that subsequent operations run as the anonymous user. |
| 40 | +
|
| 41 | + The inverse of :func:`login`. |
| 42 | + """ |
32 | 43 |
|
33 | 44 | zope.logout() |
34 | 45 |
|
35 | 46 |
|
36 | 47 | def setRoles(portal, userId, roles): |
37 | | - """Set the given user's roles to a tuple of roles.""" |
| 48 | + """Set a user's global roles to exactly the given roles. |
| 49 | +
|
| 50 | + Replaces the user's current roles rather than adding to them. |
| 51 | +
|
| 52 | + :param portal: the Plone site. |
| 53 | + :param userId: the id of the user whose roles to set, for example |
| 54 | + :data:`TEST_USER_ID`. This is the user id, not the login name. |
| 55 | + :param roles: the roles the user should have, as a sequence of role |
| 56 | + names, for example ``["Manager"]``. |
| 57 | + """ |
38 | 58 |
|
39 | 59 | userFolder = portal["acl_users"] |
40 | 60 | zope.setRoles(userFolder, userId, roles) |
@@ -105,8 +125,25 @@ def applyProfile( |
105 | 125 | archive=None, |
106 | 126 | blacklisted_steps=None, |
107 | 127 | ): |
108 | | - """Install an extension profile into the portal. The profile name |
109 | | - should be a package name and a profile name, e.g. 'my.product:default'. |
| 128 | + """Install a GenericSetup extension profile into the portal. |
| 129 | +
|
| 130 | + Runs every import step of the profile as the site owner, then rebuilds |
| 131 | + the current skin. Use this to install an add-on into the test site, |
| 132 | + typically from a layer's ``setUpPloneSite`` or directly in a test. |
| 133 | +
|
| 134 | + :param portal: the Plone site to install the profile into. |
| 135 | + :param profileName: the profile id in ``package:profile`` form, for |
| 136 | + example ``"my.product:default"``. Give it without the ``profile-`` |
| 137 | + prefix; that is added internally. |
| 138 | + :param purge_old: passed through to GenericSetup. When ``None`` (the |
| 139 | + default) GenericSetup decides; ``True`` purges existing settings |
| 140 | + before importing, ``False`` keeps them. |
| 141 | + :param ignore_dependencies: when ``True``, run only the profile's own |
| 142 | + import steps and skip the profiles it depends on. |
| 143 | + :param archive: an optional GenericSetup archive (tarball) to import |
| 144 | + from instead of the profile directory. |
| 145 | + :param blacklisted_steps: an optional sequence of import step ids to |
| 146 | + skip. |
110 | 147 | """ |
111 | 148 |
|
112 | 149 | from AccessControl import getSecurityManager |
|
0 commit comments