test: Add test for attachment limit validation
This commit is contained in:
parent
42fc8fb25c
commit
e64483ad89
1 changed files with 23 additions and 0 deletions
|
|
@ -160,6 +160,29 @@ class TestSameContent(unittest.TestCase):
|
|||
def test_saved_content(self):
|
||||
self.assertFalse(os.path.exists(get_files_path(self.dup_filename)))
|
||||
|
||||
def test_attachment_limit(self):
|
||||
doctype, docname = make_test_doc()
|
||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
||||
limit_property = make_property_setter('ToDo', None, 'max_attachments', 1, 'int', for_doctype=True)
|
||||
_file1 = frappe.get_doc({
|
||||
"doctype": "File",
|
||||
"file_name": 'test-attachment',
|
||||
"attached_to_doctype": doctype,
|
||||
"attached_to_name": docname,
|
||||
"content": 'test'})
|
||||
|
||||
_file1.insert()
|
||||
|
||||
_file2 = frappe.get_doc({
|
||||
"doctype": "File",
|
||||
"file_name": 'test-attachment',
|
||||
"attached_to_doctype": doctype,
|
||||
"attached_to_name": docname,
|
||||
"content": 'test2'})
|
||||
|
||||
self.assertRaises(frappe.exceptions.AttachmentLimitReached, _file2.insert)
|
||||
limit_property.delete()
|
||||
frappe.clear_cache(doctype='ToDo')
|
||||
|
||||
def tearDown(self):
|
||||
# File gets deleted on rollback, so blank
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue