1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-04 02:09:17 +02:00

make send and receive message test work, add some events

This commit is contained in:
holger krekel 2018-09-08 16:29:58 +02:00
parent 3265178d31
commit 4f5ded880e
8 changed files with 79 additions and 27 deletions

View file

@ -1,5 +1,6 @@
from __future__ import print_function
import re
import time
from deltachat.capi import lib
class TestLive:
@ -12,7 +13,7 @@ class TestLive:
def test_contacts(self, acfactory):
ac1 = acfactory.get_live_account(started=False)
contact1 = ac1.create_contact("some1@hello.com", name="some1")
contact1 = ac1.create_contact(email="some1@hello.com", name="some1")
assert contact1.id
assert contact1.addr == "some1@hello.com"
assert contact1.display_name == "some1"
@ -25,25 +26,50 @@ class TestLive:
chat = ac1.create_chat_by_contact(contact1)
assert chat.id
def test_basic_configure_login_ok(self, acfactory):
ac1 = acfactory.get_live_account()
def wait_successful_IMAP_SMTP_connection(self, account):
imap_ok = smtp_ok = False
while not imap_ok or not smtp_ok:
evt_name, data1, data2 = \
ac1._evlogger.get_matching("DC_EVENT_(IMAP|SMTP)_CONNECTED")
account._evlogger.get_matching("DC_EVENT_(IMAP|SMTP)_CONNECTED")
if evt_name == "DC_EVENT_IMAP_CONNECTED":
imap_ok = True
if evt_name == "DC_EVENT_SMTP_CONNECTED":
smtp_ok = True
print("** IMAP and SMTP logins successful", account.dc_context)
def wait_configuration_progress(self, account, target):
while 1:
evt_name, data1, data2 = \
account._evlogger.get_matching("DC_EVENT_CONFIGURE_PROGRESS")
if data1 >= target:
print("** CONFIG PROGRESS {}".format(target), account.dc_context)
break
def test_basic_configure_login_ok(self, acfactory):
ac1 = acfactory.get_live_account()
self.wait_successful_IMAP_SMTP_connection(ac1)
self.wait_configuration_progress(ac1, 1000)
assert ac1.get_config("mail_pw")
def test_send_message(self, acfactory):
return
ac1, ev1 = acfactory.get_live_account()
ac2, ev2 = acfactory.get_live_account()
c2 = ac2.get_self_contact()
ac1 = acfactory.get_live_account()
ac2 = acfactory.get_live_account()
c2 = ac1.create_contact(email=ac2.get_config("addr"))
chat = ac1.create_chat_by_contact(c2)
import time
time.sleep(5)
print ("sending test message")
chat.send_text_message("msg1")
assert chat.id >= lib.DC_CHAT_ID_LAST_SPECIAL
self.wait_successful_IMAP_SMTP_connection(ac1)
self.wait_successful_IMAP_SMTP_connection(ac2)
self.wait_configuration_progress(ac1, 1000)
self.wait_configuration_progress(ac2, 1000)
msgnum = chat.send_text_message("msg1")
ev = ac1._evlogger.get_matching("DC_EVENT_MSG_DELIVERED")
evt_name, data1, data2 = ev
assert data1 == chat.id
assert data2 == msgnum
starttime = time.time()
while time.time() < starttime + 20:
evt_name, data1, data2 = ac2._evlogger.get_matching("DC_EVENT_INFO")
if "1 mails read" in data2:
break
print("ignoring event", evt_name, data1, data2)