Skip to content

Commit

Permalink
test: fix test case to modified behaviour
Browse files Browse the repository at this point in the history
We throw instead of showing warning now
  • Loading branch information
ankush authored and marination committed Mar 29, 2023
1 parent 49b9ea7 commit fe76082
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
19 changes: 7 additions & 12 deletions frappe/core/doctype/docshare/test_docshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_share_disabled_add_with_ignore_permissions(self):
self.assertFalse(self.event.has_permission("share"))

# Test if behaviour is consistent for developer overrides
frappe.share.add_docshare(
frappe.share.add(
"Event", self.event.name, "test1@example.com", flags={"ignore_share_permission": True}
)

Expand All @@ -177,18 +177,13 @@ def test_share_disabled_assign_to(self):
Assigning a document to a user without access must not share the document,
if sharing disabled.
"""
from frappe.desk.form.assign_to import add, get
from frappe.desk.form.assign_to import add

frappe.share.add("Event", self.event.name, self.user, share=1)
frappe.set_user(self.user)

# Assign to 'test1@example.com'
add({"doctype": "Event", "name": self.event.name, "assign_to": ["test1@example.com"]})

# Check if assigned to 'test1@example.com'
assignments = get(dict(doctype="Event", name=self.event.name))
self.assertEqual(len(assignments), 1)

# Check if not shared with 'test1@example.com'
shared_users = [x.user for x in frappe.share.get_users("Event", self.event.name)]
self.assertNotIn("test1@example.com", shared_users)
self.assertRaises(
frappe.ValidationError,
add,
{"doctype": "Event", "name": self.event.name, "assign_to": ["test1@example.com"]},
)
4 changes: 2 additions & 2 deletions frappe/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_case(self):
# change setting
for key, value in settings_dict.items():
setattr(settings, key, value)
settings.save()
settings.save(ignore_permissions=True)
# singles are cached by default, clear to avoid flake
frappe.db.value_cache[settings] = {}
yield # yield control to calling function
Expand All @@ -54,7 +54,7 @@ def test_case(self):
settings = frappe.get_doc(doctype)
for key, value in previous_settings.items():
setattr(settings, key, value)
settings.save()
settings.save(ignore_permissions=True)
frappe.db.value_cache[settings] = {}


Expand Down

0 comments on commit fe76082

Please sign in to comment.