diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index 6089a5362..702897281 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -509,7 +509,7 @@ class Account(object): # meta API for start/stop and event based processing # - def start_threads(self, mvbox=False, sentbox=False): + def start_threads(self): """ start IMAP/SMTP threads (and configure account if it hasn't happened). :raises: ValueError if 'addr' or 'mail_pw' are not configured. @@ -517,7 +517,7 @@ class Account(object): """ if not self.is_configured(): self.configure() - self._threads.start(mvbox=mvbox, sentbox=sentbox) + self._threads.start() def stop_threads(self, wait=True): """ stop IMAP/SMTP threads. """ @@ -569,16 +569,15 @@ class IOThreads: def is_started(self): return len(self._name2thread) > 0 - def start(self, imap=True, smtp=True, mvbox=False, sentbox=False): + def start(self): assert not self.is_started() - if imap: - self._start_one_thread("inbox", self.imap_thread_run) - if mvbox: + self._start_one_thread("inbox", self.imap_thread_run) + self._start_one_thread("smtp", self.smtp_thread_run) + + if int(self.account.get_config("mvbox_watch")): self._start_one_thread("mvbox", self.mvbox_thread_run) - if sentbox: + if int(self.account.get_config("sentbox_watch")): self._start_one_thread("sentbox", self.sentbox_thread_run) - if smtp: - self._start_one_thread("smtp", self.smtp_thread_run) def _start_one_thread(self, name, func): self._name2thread[name] = t = threading.Thread(target=func, name=name) @@ -600,8 +599,10 @@ class IOThreads: lib.dc_interrupt_imap_idle(self._dc_context) lib.dc_interrupt_smtp_idle(self._dc_context) - lib.dc_interrupt_mvbox_idle(self._dc_context) - lib.dc_interrupt_sentbox_idle(self._dc_context) + if "mvbox" in self._name2thread: + lib.dc_interrupt_mvbox_idle(self._dc_context) + if "sentbox" in self._name2thread: + lib.dc_interrupt_sentbox_idle(self._dc_context) if wait: for name, thread in self._name2thread.items(): thread.join() diff --git a/python/tests/conftest.py b/python/tests/conftest.py index 753114eee..50b35beb1 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -228,8 +228,10 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig, datadir): ac, configdict = self.get_online_config( pre_generated_key=pre_generated_key) configdict.update(config) + configdict["mvbox_watch"] = str(int(mvbox)) + configdict["mvbox_move"] = "1" ac.configure(**configdict) - ac.start_threads(mvbox=mvbox, sentbox=sentbox) + ac.start_threads() return ac def get_one_online_account(self, pre_generated_key=True): @@ -255,7 +257,13 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig, datadir): self._preconfigure_key(ac, account.get_config("addr")) ac._evtracker.init_time = self.init_time ac._evtracker.set_timeout(30) - ac.configure(addr=account.get_config("addr"), mail_pw=account.get_config("mail_pw")) + ac.configure( + addr=account.get_config("addr"), + mail_pw=account.get_config("mail_pw"), + mvbox_watch=account.get_config("mvbox_watch"), + mvbox_move=account.get_config("mvbox_move"), + sentbox_watch=account.get_config("sentbox_watch"), + ) ac.start_threads() return ac diff --git a/python/tests/test_increation.py b/python/tests/test_increation.py index a1b4384ac..d2f16285f 100644 --- a/python/tests/test_increation.py +++ b/python/tests/test_increation.py @@ -92,21 +92,21 @@ class TestOnlineInCreation: lp.sec("wait for the messages to be delivered to SMTP") ev = ac1._evtracker.get_matching("DC_EVENT_MSG_DELIVERED") - assert ev[1] == chat.id - assert ev[2] == prepared_original.id + assert ev.data1 == chat.id + assert ev.data2 == prepared_original.id ev = ac1._evtracker.get_matching("DC_EVENT_MSG_DELIVERED") - assert ev[1] == chat2.id - assert ev[2] == forwarded_id + assert ev.data1 == chat2.id + assert ev.data2 == forwarded_id lp.sec("wait1 for original or forwarded messages to arrive") ev1 = ac2._evtracker.get_matching("DC_EVENT_MSGS_CHANGED") - assert ev1[1] > const.DC_CHAT_ID_LAST_SPECIAL - received_original = ac2.get_message_by_id(ev1[2]) + assert ev1.data1 > const.DC_CHAT_ID_LAST_SPECIAL + received_original = ac2.get_message_by_id(ev1.data2) assert cmp(received_original.filename, orig, shallow=False) lp.sec("wait2 for original or forwarded messages to arrive") ev2 = ac2._evtracker.get_matching("DC_EVENT_MSGS_CHANGED") - assert ev2[1] > const.DC_CHAT_ID_LAST_SPECIAL - assert ev2[1] != ev1[1] - received_copy = ac2.get_message_by_id(ev2[2]) + assert ev2.data1 > const.DC_CHAT_ID_LAST_SPECIAL + assert ev2.data1 != ev1.data1 + received_copy = ac2.get_message_by_id(ev2.data2) assert cmp(received_copy.filename, orig, shallow=False)