Unit Test for cancel submitable doctype
This commit is contained in:
parent
9cf251e53e
commit
0b0b2f46fc
1 changed files with 54 additions and 1 deletions
|
|
@ -26,7 +26,10 @@ class TestDocType(unittest.TestCase):
|
|||
}],
|
||||
"permissions": [{
|
||||
"role": "System Manager",
|
||||
"read": 1
|
||||
"read": 1,
|
||||
"submit": 1,
|
||||
"cancel": 1,
|
||||
|
||||
}],
|
||||
"name": name
|
||||
})
|
||||
|
|
@ -295,3 +298,53 @@ class TestDocType(unittest.TestCase):
|
|||
field_1.search_index = 1
|
||||
|
||||
self.assertRaises(CannotIndexedError, doc.insert)
|
||||
|
||||
def test_cancel_link_doctype(self):
|
||||
import json
|
||||
from frappe.desk.form.linked_with import get_submitted_linked_docs, cancel_all_linked_docs
|
||||
|
||||
#create doctype
|
||||
link_doc = self.new_doctype('Test Linked Doctype')
|
||||
link_doc.is_submittable = 1
|
||||
field_1 = link_doc.append('fields', {})
|
||||
link_doc.insert()
|
||||
|
||||
doc = self.new_doctype('Test Doctype')
|
||||
doc.is_submittable = 1
|
||||
field_2 = doc.append('fields', {})
|
||||
field_2.label = 'Test Linked Doctype'
|
||||
field_2.fieldname = 'test_linked_doctype'
|
||||
field_2.fieldtype = 'Link'
|
||||
field_2.options = 'Test Linked Doctype'
|
||||
doc.insert()
|
||||
|
||||
# create doctype data
|
||||
data_link_doc = frappe.new_doc('Test Linked Doctype')
|
||||
data_link_doc.some_fieldname = 'Data1'
|
||||
data_link_doc.insert()
|
||||
data_link_doc.save()
|
||||
data_link_doc.submit()
|
||||
|
||||
data_doc = frappe.new_doc('Test Doctype')
|
||||
data_doc.some_fieldname = 'Data1'
|
||||
data_doc.test_linked_doctype = data_link_doc.name
|
||||
data_doc.insert()
|
||||
data_doc.save()
|
||||
data_doc.submit()
|
||||
|
||||
docs = get_submitted_linked_docs(link_doc.name, data_link_doc.name)
|
||||
dump_docs = json.dumps(docs.get('docs'))
|
||||
cancel_all_linked_docs(dump_docs)
|
||||
data_link_doc.cancel()
|
||||
data_doc.load_from_db()
|
||||
self.assertEqual(data_link_doc.docstatus, 2)
|
||||
self.assertEqual(data_doc.docstatus, 2)
|
||||
|
||||
# delete doctype record
|
||||
data_doc.delete()
|
||||
data_link_doc.delete()
|
||||
|
||||
# delete doctype
|
||||
link_doc.delete()
|
||||
doc.delete()
|
||||
frappe.db.commit()
|
||||
Loading…
Add table
Reference in a new issue