Procházet zdrojové kódy

[fix] [email] tests

version-14
Rushabh Mehta před 9 roky
rodič
revize
fd92c72cbe
2 změnil soubory, kde provedl 9 přidání a 5 odebrání
  1. +1
    -0
      frappe/email/doctype/email_account/test_email_account.py
  2. +8
    -5
      frappe/email/queue.py

+ 1
- 0
frappe/email/doctype/email_account/test_email_account.py Zobrazit soubor

@@ -16,6 +16,7 @@ class TestEmailAccount(unittest.TestCase):
def setUp(self):
email_account = frappe.get_doc("Email Account", "_Test Email Account 1")
email_account.db_set("enable_incoming", 1)
frappe.db.sql('delete from `tabEmail Queue`')

def tearDown(self):
email_account = frappe.get_doc("Email Account", "_Test Email Account 1")


+ 8
- 5
frappe/email/queue.py Zobrazit soubor

@@ -275,18 +275,21 @@ def flush(from_test=False):
def make_cache_queue():
'''cache values in queue before sendign'''
cache = frappe.cache()
cache.delete_value('cache_email_queue')

for l in frappe.db.sql('''select name from `tabEmail Queue`
emails = frappe.db.sql('''select name from `tabEmail Queue`
where status='Not Sent' and (send_after is null or send_after < %(now)s)
order by priority desc, creation asc
limit 500''', { 'now': now_datetime() }):
cache.lpush('cache_email_queue', l[0])
limit 500''', { 'now': now_datetime() })

cache.delete_value('cache_email_queue')
for e in emails:
cache.lpush('cache_email_queue', e[0])

def send_one(email, smtpserver=None, auto_commit=True, now=False):
'''Send Email Queue with given smtpserver'''

email = frappe.db.sql('''select name, status, communication, message, sender, recipient
email = frappe.db.sql('''select name, status, communication,
message, sender, recipient, reference_doctype,
from `tabEmail Queue` where name=%s for update''', email, as_dict=True)[0]
if email.status != 'Not Sent':
# rollback to release lock and return


Načítá se…
Zrušit
Uložit