Merge branch 'develop' into core-test-coverage
This commit is contained in:
commit
aea6e55a50
5 changed files with 27 additions and 2 deletions
|
|
@ -109,3 +109,13 @@ class TestServerScript(unittest.TestCase):
|
|||
"""Raise AttributeError if method not found in Namespace"""
|
||||
note = frappe.get_doc({"doctype": "Note", "title": "Test Note: Server Script"})
|
||||
self.assertRaises(AttributeError, note.insert)
|
||||
|
||||
def test_syntax_validation(self):
|
||||
server_script = scripts[0]
|
||||
server_script["script"] = "js || code.?"
|
||||
|
||||
with self.assertRaises(frappe.ValidationError) as se:
|
||||
frappe.get_doc(doctype="Server Script", **server_script).insert()
|
||||
|
||||
self.assertTrue("invalid python code" in str(se.exception).lower(),
|
||||
msg="Python code validation not working")
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ def execute_cmd(cmd, from_async=False):
|
|||
try:
|
||||
method = get_attr(cmd)
|
||||
except Exception as e:
|
||||
frappe.throw(_('Invalid Method'))
|
||||
frappe.throw(_('Failed to get method for command {0} with {1}').format(cmd, e))
|
||||
|
||||
if from_async:
|
||||
method = method.queue
|
||||
|
|
|
|||
|
|
@ -507,6 +507,7 @@ class Document(BaseDocument):
|
|||
d._validate_selects()
|
||||
d._validate_non_negative()
|
||||
d._validate_length()
|
||||
d._validate_code_fields()
|
||||
d._extract_images_from_text_editor()
|
||||
d._sanitize_content()
|
||||
d._save_passwords()
|
||||
|
|
@ -1064,7 +1065,10 @@ class Document(BaseDocument):
|
|||
self.set("modified", now())
|
||||
self.set("modified_by", frappe.session.user)
|
||||
|
||||
self.load_doc_before_save()
|
||||
# load but do not reload doc_before_save because before_change or on_change might expect it
|
||||
if not self.get_doc_before_save():
|
||||
self.load_doc_before_save()
|
||||
|
||||
# to trigger notification on value change
|
||||
self.run_method('before_change')
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ frappe.ui.form.ControlCode = class ControlCode extends frappe.ui.form.ControlTex
|
|||
this.editor = ace.edit(this.ace_editor_target.get(0));
|
||||
this.editor.setTheme('ace/theme/tomorrow');
|
||||
this.editor.setOption("showPrintMargin", false);
|
||||
this.editor.setOption("wrap", this.df.wrap);
|
||||
this.set_language();
|
||||
|
||||
// events
|
||||
|
|
|
|||
|
|
@ -121,6 +121,16 @@ class TestWorkflow(unittest.TestCase):
|
|||
self.workflow.states[1].doc_status = 0
|
||||
self.workflow.save()
|
||||
|
||||
def test_syntax_error_in_transition_rule(self):
|
||||
self.workflow.transitions[0].condition = 'doc.status =! "Closed"'
|
||||
|
||||
with self.assertRaises(frappe.ValidationError) as se:
|
||||
self.workflow.save()
|
||||
|
||||
self.assertTrue("invalid python code" in str(se.exception).lower(),
|
||||
msg="Python code validation not working")
|
||||
|
||||
|
||||
def create_todo_workflow():
|
||||
if frappe.db.exists('Workflow', 'Test ToDo'):
|
||||
frappe.delete_doc('Workflow', 'Test ToDo')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue