Skip to content

Commit

Permalink
fix(tests): tests and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehta committed Feb 13, 2019
1 parent b982f83 commit d610ce9
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bandit.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
skips: ['B605', 'B404', 'B603', 'B607']
skips: ['E0203', 'B605', 'B404', 'B603', 'B607']
4 changes: 2 additions & 2 deletions frappe/core/doctype/comment/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// For license information, please see license.txt

frappe.ui.form.on('Comment', {
refresh: function(frm) {
// refresh: function(frm) {

}
// }
});
2 changes: 1 addition & 1 deletion frappe/core/doctype/comment/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def update_comments_in_parent(reference_doctype, reference_name, _comments):
try:
# use sql, so that we do not mess with the timestamp
frappe.db.sql("""update `tab{0}` set `_comments`=%s where name=%s""".format(reference_doctype),
(json.dumps(_comments), reference_name))
(json.dumps(_comments[-50:]), reference_name)) # nosec

except Exception as e:
if frappe.db.is_column_missing(e) and getattr(frappe.local, 'request', None):
Expand Down
16 changes: 16 additions & 0 deletions frappe/core/doctype/comment/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,26 @@ def test_public_comment(self):
from frappe.website.doctype.blog_post.test_blog_post import make_test_blog
test_blog = make_test_blog()

frappe.db.sql("delete from `tabComment` where reference_doctype = 'Blog Post'")

from frappe.templates.includes.comments.comments import add_comment
add_comment('hello', 'test@test.com', 'Good Tester',
'Blog Post', test_blog.name, test_blog.route)

self.assertEqual(frappe.get_all('Comment', fields = ['*'], filters = dict(
reference_doctype = test_blog.doctype,
reference_name = test_blog.name
))[0].published, 1)

frappe.db.sql("delete from `tabComment` where reference_doctype = 'Blog Post'")

add_comment('pleez vizits my site http://mysite.com', 'test@test.com', 'bad commentor',
'Blog Post', test_blog.name, test_blog.route)

self.assertEqual(frappe.get_all('Comment', fields = ['*'], filters = dict(
reference_doctype = test_blog.doctype,
reference_name = test_blog.name
))[0].published, 0)



4 changes: 2 additions & 2 deletions frappe/model/delete_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def delete_references(doctype, reference_doctype, reference_name,
reference_doctype_field = 'reference_doctype', reference_name_field = 'reference_name'):
frappe.db.sql('''delete from `tab{0}`
where {1}=%s and {2}=%s'''.format(doctype, reference_doctype_field, reference_name_field),
(reference_doctype, reference_name))
(reference_doctype, reference_name)) # nosec

def clear_references(doctype, reference_doctype, reference_name,
reference_doctype_field = 'reference_doctype', reference_name_field = 'reference_name'):
Expand All @@ -295,7 +295,7 @@ def clear_references(doctype, reference_doctype, reference_name,
{1}=NULL, {2}=NULL
where
{1}=%s and {2}=%s'''.format(doctype, reference_doctype_field, reference_name_field),
(reference_doctype, reference_name))
(reference_doctype, reference_name)) # nosec


def insert_feed(doc):
Expand Down
2 changes: 1 addition & 1 deletion frappe/public/js/frappe/desk.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ frappe.Application = Class.extend({
}
});
dialog.set_primary_action(__('Login'), () => {
me.dialog.set_message(__('Authenticating...'));
dialog.set_message(__('Authenticating...'));
frappe.call({
method: 'login',
args: {
Expand Down
2 changes: 1 addition & 1 deletion frappe/website/doctype/blog_post/test_blog_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def make_test_blog():
category_name = 'Test Blog Category',
title='Test Blog Category')).insert()
if not frappe.db.exists('Blogger', 'test-blogger'):
blogger = frappe.get_doc(dict(
frappe.get_doc(dict(
doctype = 'Blogger',
short_name='test-blogger',
full_name='Test Blogger')).insert()
Expand Down

0 comments on commit d610ce9

Please sign in to comment.