Skip to content

Commit

Permalink
test_model.AccountTests: mock user with the wanted account as user id.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritsvanrees committed Aug 5, 2024
1 parent 084066e commit cc7e7a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/euphorie/client/tests/test_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from AccessControl.PermissionRole import _what_not_even_god_should_do
from AccessControl.users import nobody
from AccessControl.users import SimpleUser
from datetime import timedelta
from euphorie.client import config
from euphorie.client import model
Expand Down Expand Up @@ -391,9 +392,11 @@ def testSessions(self):
session.add(account1)
account1.group = group1
group2.parent = group1
session.flush()
from functools import partial

with mock.patch("plone.api.user.get_current", return_value=nobody):
user1 = SimpleUser(str(account1.id), "", ("Member",), [])
with mock.patch("plone.api.user.get_current", return_value=user1):
add_survey = partial(model.SurveySession, account=account1)
survey1 = add_survey(zodb_path="1")
session.add(survey1)
Expand Down Expand Up @@ -421,7 +424,9 @@ def testSessionAcquisition(self):
account2 = model.Account(loginname="account2")
session.add(account2)
account2.group = group2
with mock.patch("plone.api.user.get_current", return_value=nobody):
session.flush()
user1 = SimpleUser(str(account1.id), "", ("Member",), [])
with mock.patch("plone.api.user.get_current", return_value=user1):
survey1 = model.SurveySession(
account=account1,
group=group1,
Expand Down

0 comments on commit cc7e7a7

Please sign in to comment.