[add] catch errors flake8 (#3800)

This commit is contained in:
Rushabh Mehta 2017-07-27 11:34:44 +05:30 committed by GitHub
parent 1332710982
commit aef98daae4
10 changed files with 36 additions and 10 deletions

View file

@ -15,6 +15,9 @@ services:
- mysql
install:
- pip install flake8 # pytest
# stop the build if there are Python syntax errors or undefined names
- flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
- sudo rm /etc/apt/sources.list.d/docker.list
- sudo apt-get purge -y mysql-common mysql-server mysql-client
- nvm install v7.10.0

View file

@ -330,10 +330,10 @@ class DocType(Document):
def make_controller_template(self):
"""Make boilerplate controller template."""
make_boilerplate("controller.py", self)
make_boilerplate("controller._py", self)
if not (self.istable or self.issingle):
make_boilerplate("test_controller.py", self.as_dict())
make_boilerplate("test_controller._py", self.as_dict())
if not self.istable:
make_boilerplate("controller.js", self.as_dict())

View file

@ -26,7 +26,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Domain",
"length": 0,
@ -54,7 +54,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-06-16 13:03:25.430679",
"modified": "2017-07-26 21:29:00.353105",
"modified_by": "Administrator",
"module": "Core",
"name": "Domain",

View file

@ -0,0 +1,23 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Domain", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially('Domain', [
// insert a new Domain
() => frappe.tests.make([
// values to be set
{key: 'value'}
]),
() => {
assert.equal(cur_frm.doc.key, 'value');
},
() => done()
]);
});

View file

@ -7,7 +7,6 @@ import frappe
from frappe.model.document import Document
class HasRole(Document):
def validate(self):
if cint(self.get("__islocal")) and frappe.db.exists("Has Role", {
"parent": self.parent, "role": self.role}):
def before_insert(self):
if frappe.db.exists("Has Role", {"parent": self.parent, "role": self.role}):
frappe.throw(frappe._("User '{0}' already has the role '{1}'").format(self.parent, self.role))

View file

@ -13,7 +13,6 @@ from frappe.utils.background_jobs import enqueue
from frappe.utils.scheduler import log
from frappe.email.queue import send
from frappe.email.doctype.email_group.email_group import add_subscribers
from frappe.utils.file_manager import get_file
from frappe.utils import parse_addr
@ -68,7 +67,7 @@ class Newsletter(Document):
files = frappe.get_all("File", fields = ["name"], filters = {"attached_to_doctype": "Newsletter",
"attached_to_name":self.name}, order_by="creation desc")
for file in files:
for a in files:
try:
# these attachments will be attached on-demand
# and won't be stored in the message

View file

@ -17,7 +17,7 @@ class GSuiteSettings(Document):
def get_access_token(self):
if not self.refresh_token:
raise UserError(_("Google GSuite is not configured."))
raise frappe.ValidationError(_("Google GSuite is not configured."))
data = {
'client_id': self.client_id,
'client_secret': self.get_password(fieldname='client_secret',raise_exception=False),

View file

@ -206,6 +206,8 @@ def get_app_publisher(module):
def make_boilerplate(template, doc, opts=None):
target_path = get_doc_path(doc.module, doc.doctype, doc.name)
template_name = template.replace("controller", scrub(doc.name))
if template_name.endswith('._py'):
template_name = template_name[:-4] + '.py'
target_file_path = os.path.join(target_path, template_name)
if not doc: doc = {}