-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AttributeError occurs in creator_name when the user is missing
- Loading branch information
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from plone import api | ||
from plone.app.testing import login | ||
from plone.app.testing import SITE_OWNER_NAME | ||
from plone.app.testing import SITE_OWNER_PASSWORD | ||
|
@@ -112,3 +113,21 @@ def test_update_locked_object_with_token_succeeds(self): | |
transaction.commit() | ||
self.assertEqual(response.status_code, 204) | ||
self.assertEqual(self.doc.Title(), "New Title") | ||
|
||
def test_lock_user_removed(self): | ||
lockable = ILockable(self.doc) | ||
api.user.create( | ||
username="foo", | ||
email="[email protected]", | ||
roles=["Manager"], | ||
) | ||
with api.env.adopt_user(username="foo"): | ||
lockable.lock() | ||
api.user.delete(username="foo") | ||
transaction.commit() | ||
# the user that locked the object is no longer present | ||
response = self.api_session.get("/@lock") | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response.json()["creator"], "foo") | ||
self.assertEqual(response.json()["creator_name"], "foo") | ||
self.assertTrue(lockable.locked()) |