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

emit and look for DC_EVENT_(SMTP|IMAP)_CONNECTED events which are INFO events so that we can also for other events convert the C-code easily (just use "dc_log_event" instead of "dc_log_info")

This commit is contained in:
holger krekel 2018-09-08 14:06:16 +02:00
parent 1c77187d5a
commit 3265178d31
9 changed files with 51 additions and 13 deletions

View file

@ -34,6 +34,7 @@ def acfactory(pytestconfig, tmpdir, request):
configdict = self.configlist.pop(0)
tmpdb = tmpdir.join("testdb%d" % self.count)
ac = Account(tmpdb.strpath)
ac._evlogger.set_timeout(10)
ac.set_config(**configdict)
if started:
ac.start()

2
python/setup.cfg Normal file
View file

@ -0,0 +1,2 @@
[devpi:upload]
formats = sdist.tgz,bdist_wheel

View file

@ -42,21 +42,26 @@ class EventLogger:
self._event_queue = Queue()
self._debug = debug
self._ctxinfo = str(self.dc_context).strip(">").split()[-1]
self._timeout = None
def __call__(self, evt_name, data1, data2):
self._log_event(evt_name, data1, data2)
self._event_queue.put((evt_name, data1, data2))
def set_timeout(self, timeout):
self._timeout = timeout
def get(self, timeout=None, check_error=True):
timeout = timeout or self._timeout
ev = self._event_queue.get(timeout=timeout)
if check_error:
assert ev[0] != "DC_EVENT_ERROR"
return ev
def get_matching(self, event_name_regex, timeout=None):
rex = re.compile(event_name_regex + ".*")
def get_matching(self, event_name_regex):
rex = re.compile("(?:{}).*".format(event_name_regex))
while 1:
ev = self.get(timeout=timeout)
ev = self.get()
if rex.match(ev[0]):
return ev

View file

@ -30,10 +30,10 @@ class TestLive:
imap_ok = smtp_ok = False
while not imap_ok or not smtp_ok:
evt_name, data1, data2 = \
ac1._evlogger.get_matching("DC_EVENT_INFO", timeout=5)
if re.match("imap-login.*ok.", data2.lower()):
ac1._evlogger.get_matching("DC_EVENT_(IMAP|SMTP)_CONNECTED")
if evt_name == "DC_EVENT_IMAP_CONNECTED":
imap_ok = True
if re.match("smtp-login.*ok.", data2.lower()):
if evt_name == "DC_EVENT_SMTP_CONNECTED":
smtp_ok = True
assert ac1.get_config("mail_pw")