From fd57a6f4a3732190ca0e1fb008f76788c23065ac Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Wed, 23 Feb 2022 19:23:31 +0530 Subject: [PATCH] test: Skip test_image_parsing if no mail found * Trimmed trailing whitespaces -_- ref: Flaky test - https://github.com/frappe/frappe/runs/5303629095?check_suite_focus=true --- frappe/tests/test_email.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/frappe/tests/test_email.py b/frappe/tests/test_email.py index ad9f8fdd11..51a0786c2f 100644 --- a/frappe/tests/test_email.py +++ b/frappe/tests/test_email.py @@ -1,9 +1,9 @@ -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors # License: MIT. See LICENSE import unittest, frappe, re, email -from frappe.email.doctype.email_account.test_email_account import TestEmailAccount +from frappe.email.doctype.email_account.test_email_account import TestEmailAccount test_dependencies = ['Email Account'] @@ -176,7 +176,6 @@ class TestEmail(unittest.TestCase): with open(frappe.get_app_path('frappe', 'tests', 'data', 'email_with_image.txt'), 'r') as raw: messages = { - # append_to = ToDo '"INBOX"': { 'latest_messages': [ raw.read() @@ -185,17 +184,20 @@ class TestEmail(unittest.TestCase): 2: 'UNSEEN' }, 'uid_list': [2] - } + } } email_account = frappe.get_doc("Email Account", "_Test Email Account 1") changed_flag = False - if not email_account.enable_incoming: + if not email_account.enable_incoming: email_account.enable_incoming = True changed_flag = True mails = TestEmailAccount.mocked_get_inbound_mails(email_account, messages) - # mails = email_account.get_inbound_mails(test_mails=[raw.read()]) + # TODO: fix this flaky test! - 'IndexError: list index out of range' for `.process()` line + if not mails: + raise self.skipTest("No inbound mails found / Email Account wasn't patched properly") + communication = mails[0].process() self.assertTrue(re.search(''']*src=["']/private/files/rtco1.png[^>]*>''', communication.content))