Bläddra i källkod

fixed tests

version-14
Anand Doshi 9 år sedan
förälder
incheckning
1511d6be81
4 ändrade filer med 14 tillägg och 2 borttagningar
  1. +1
    -1
      frappe/core/doctype/doctype/doctype.py
  2. +6
    -0
      frappe/core/doctype/file/test_file.py
  3. +5
    -0
      frappe/email/doctype/email_account/test_email_account.py
  4. +2
    -1
      frappe/utils/file_manager.py

+ 1
- 1
frappe/core/doctype/doctype/doctype.py Visa fil

@@ -203,7 +203,7 @@ class DocType(Document):
return max_idx and max_idx[0][0] or 0 return max_idx and max_idx[0][0] or 0


def validate_fields_for_doctype(doctype): 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 # this is separate because it is also called via custom field
def validate_fields(meta): def validate_fields(meta):


+ 6
- 0
frappe/core/doctype/file/test_file.py Visa fil

@@ -15,6 +15,12 @@ class TestFile(unittest.TestCase):
self.delete_test_data() self.delete_test_data()
self.upload_file() 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): def delete_test_data(self):
for f in frappe.db.sql('''select name, file_name from tabFile where 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'''): is_home_folder = 0 and is_attachments_folder = 0 order by rgt-lft asc'''):


+ 5
- 0
frappe/email/doctype/email_account/test_email_account.py Visa fil

@@ -58,6 +58,11 @@ class TestEmailAccount(unittest.TestCase):
attachments = get_attachments(comm.doctype, comm.name) attachments = get_attachments(comm.doctype, comm.name)
self.assertTrue("erpnext-conf-14.png" in [f.file_name for f in attachments]) 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): def test_outgoing(self):
frappe.flags.sent_mail = None frappe.flags.sent_mail = None
make(subject = "test-mail-000", content="test mail 000", recipients="test_receiver@example.com", make(subject = "test-mail-000", content="test mail 000", recipients="test_receiver@example.com",


+ 2
- 1
frappe/utils/file_manager.py Visa fil

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

return f return f


def get_file_data_from_hash(content_hash): def get_file_data_from_hash(content_hash):


Laddar…
Avbryt
Spara