Skip to content

Commit

Permalink
Add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroel committed Oct 31, 2016
1 parent 1b5a545 commit 636cf96
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/plone/api/tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ def test_get_groups_nonexistant_user(self):
with self.assertRaises(UserNotFoundError):
api.group.get_groups(username='theurbanspaceman')

def test_get_groups_anonymous(self):
from AccessControl.users import nobody
# In test the anonymous user is aq wrapped in /plone/acl_users
# > self.portal.acl_users in api.user.get_current().aq_chain
# >>> True
# In practice is is aq wrapped in /acl_users
# > self.context.acl_users in api.user.get_current().aq_chain
# >>> False
# We'll force the user into /acl_users, which has no portal_groups.
user = nobody.__of__(api.portal.get().__parent__.acl_users)
groups = api.group.get_groups(user=user)
self.assertEqual(groups, []) # should be empty

def test_delete_contraints(self):
"""Test deleting a group without passing parameters."""
from plone.api.exc import MissingParameterError
Expand Down

0 comments on commit 636cf96

Please sign in to comment.