Merge branch 'develop' of https://github.com/frappe/frappe into frappe-scanner

This commit is contained in:
Saqib Ansari 2021-08-09 14:02:47 +05:30
commit 37b59acd2f
5 changed files with 23 additions and 1 deletions

View file

@ -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")

View file

@ -543,7 +543,7 @@ class Database(object):
"""
if not doctype in self.value_cache:
self.value_cache = self.value_cache[doctype] = {}
self.value_cache[doctype] = {}
if fieldname in self.value_cache[doctype]:
return self.value_cache[doctype][fieldname]

View file

@ -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()

View file

@ -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

View file

@ -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')