fixed tests

This commit is contained in:
Anand Doshi 2015-10-22 15:18:32 +05:30
parent 6670ecd4f8
commit 1511d6be81
4 changed files with 14 additions and 2 deletions

View file

@ -203,7 +203,7 @@ class DocType(Document):
return max_idx and max_idx[0][0] or 0
def validate_fields_for_doctype(doctype):
validate_fields(frappe.get_meta(doctype))
validate_fields(frappe.get_meta(doctype, cached=False))
# this is separate because it is also called via custom field
def validate_fields(meta):

View file

@ -15,6 +15,12 @@ class TestFile(unittest.TestCase):
self.delete_test_data()
self.upload_file()
def tearDown(self):
try:
frappe.get_doc("File", {"file_name": "file_copy.txt"}).delete()
except frappe.DoesNotExistError:
pass
def delete_test_data(self):
for f in frappe.db.sql('''select name, file_name from tabFile where
is_home_folder = 0 and is_attachments_folder = 0 order by rgt-lft asc'''):

View file

@ -58,6 +58,11 @@ class TestEmailAccount(unittest.TestCase):
attachments = get_attachments(comm.doctype, comm.name)
self.assertTrue("erpnext-conf-14.png" in [f.file_name for f in attachments])
# cleanup
existing_file = frappe.get_doc({'doctype': 'File', 'file_name': 'erpnext-conf-14.png'})
frappe.delete_doc("File", existing_file.name)
delete_file_from_filesystem(existing_file)
def test_outgoing(self):
frappe.flags.sent_mail = None
make(subject = "test-mail-000", content="test mail 000", recipients="test_receiver@example.com",

View file

@ -164,9 +164,10 @@ def save_file(fname, content, dt, dn, folder=None, decode=False):
f = frappe.get_doc(file_data)
f.flags.ignore_permissions = True
try:
f.insert();
f.insert()
except frappe.DuplicateEntryError:
return frappe.get_doc("File", f.duplicate_entry)
return f
def get_file_data_from_hash(content_hash):