-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_current_account: catch exception when portal cannot be found. #757
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to not import new stuff from plone.api
.
Also, I would consider using a mock rather than catching that expression, e.g.:
with mock.patch("plone.api.user.get_current", return_value=DummyUser(email="...")):
or
with mock.patch("plone.api.user.get_current", return_value=None):
In these unit tests no portal is available, which trips up our test in combination with some third party code.
Ah, we are using |
cf29e24
to
084066e
Compare
Ah! Now I was able to grok it... There it might have sense to catch the |
survey3 = add_survey(zodb_path="3", group=group2) | ||
session.add(survey3) | ||
session.flush() | ||
with mock.patch("plone.api.user.get_current", return_value=nobody): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that in this case the return_value should be sqlalchemy account, i.e. account1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the PR to do this. But then the tests actually fail again: in the osha.oira
subscriber get_current_account
then gets an actual account, and then the subscriber tries to get the portal and this fails.
So maybe we should abandon this, and instead catch the error in osha.oira
as you suggest. I will push a PR for that.
…portal. This may happen in unit tests. See euphorie/Euphorie#757
c6542d8
to
cc7e7a7
Compare
I think this can be closed. |
This can happen in unit tests without test layer.
For example in a buildout with osha.oira: