Ticket #12373 (confirmed Feature Request)
plone.app.testing login as SITE_OWNER_NAME raises an exception
Reported by: | glenfant | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 4.x |
Component: | Backend (Python) | Version: | 4.1 |
Keywords: | Cc: |
Description
... when login as TEST_USER_NAME works as expected. Unless I didn't understand anything.
Hi,
I'm a happy user of plone.app.testing that makes tests really easier. Thants to its parents.
Trying to login as Manager raises an exception :
def test_role_permissions(self): """Something is wrong with the portal owner """ from plone.app.testing import SITE_OWNER_NAME, TEST_USER_NAME, login # This one works as expected login(self.portal, TEST_USER_NAME) # This one raises an AttributeError login(self.portal, SITE_OWNER_NAME)
Here is the traceback
Error in test test_role_permissions (aws.authrss.tests.test_views.TestViews) Traceback (most recent call last): File "/Users/glenfant/zope/instances/plone41/eggs/unittest2-0.5.1-py2.6.egg/unittest2/case.py", line 340, in run testMethod() File "/Users/glenfant/zope/instances/plone41/src/aws.authrss/src/aws/authrss/tests/test_views.py", line 60, in test_role_permissions login(self.portal, SITE_OWNER_NAME) File "/Users/glenfant/zope/instances/plone41/eggs/plone.app.testing-4.0.2-py2.6.egg/plone/app/testing/helpers.py", line 24, in login z2.login(portal['acl_users'], userName) File "/Users/glenfant/zope/instances/plone41/eggs/plone.testing-4.0.2-py2.6.egg/plone/testing/z2.py", line 166, in login user = user.__of__(userFolder) AttributeError: 'NoneType' object has no attribute '__of__'
Note that curiously, login as "SITE_OWNER_NAME" using a test browser as indicated in comment 3 of ticket:11674 works as expected.
Did I miss something or is it a bug ?
Change History
comment:1 Changed 4 years ago by kleist
- Component changed from Unknown to Infrastructure
- Milestone set to 4.x
comment:2 Changed 4 years ago by maurits
Not sure if this can be called a bug. It might be called a feature request to have a function that does the same as loginAsPortalOwner does in PloneTestCase.
plone.app.testing itself uses this code to login as site owner:
from plone.testing import z2 z2.login(app['acl_users'], SITE_OWNER_NAME)
comment:3 Changed 4 years ago by kleist
- Status changed from new to confirmed
- Type changed from Bug to Feature Request
- Version set to 4.1
- Component changed from Infrastructure to Sysadmin and Development Infrastructure
comment:4 Changed 4 years ago by martior
- Component changed from Sysadmin and Development Infrastructure to Unknown
Not sure where this should go, but the AI-team does not want it.
comment:6 Changed 2 years ago by regebro
Instead of
login(self.portal, SITE_OWNER_NAME)
you can do
login(self.app, SITE_OWNER_NAME)
This is because SITE_OWNER_NAME is defined in the root acl_users and not in the site. I think this is acceptable and doesn't necessarily need fixing, but can be solved with better documentation.