From fb33c3137819d373f7f640fc73d153b439d2dce6 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Wed, 26 Feb 2020 14:15:28 +0100 Subject: [PATCH] fix a couple of issues wrt to configuring move/mvbox behaviour in tests --- python/src/deltachat/account.py | 1 - python/src/deltachat/hookspec.py | 1 - python/tests/conftest.py | 13 +++++++------ python/tests/test_account.py | 32 ++++++++++++++++---------------- python/tests/test_lowlevel.py | 2 +- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index f138b4450..946a515b7 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -58,7 +58,6 @@ class Account(object): atexit.register(self.shutdown) self._shutdown_event = Event() - @hookspec.account_hookimpl def process_ffi_event(self, ffi_event): name = ffi_event.name diff --git a/python/src/deltachat/hookspec.py b/python/src/deltachat/hookspec.py index 159b4a3f8..da99a1660 100644 --- a/python/src/deltachat/hookspec.py +++ b/python/src/deltachat/hookspec.py @@ -68,4 +68,3 @@ class Global: @global_hookspec def account_after_shutdown(self, account, dc_context): """ Called after the account has been shutdown. """ - diff --git a/python/tests/conftest.py b/python/tests/conftest.py index c470b2236..ea545012d 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -223,27 +223,28 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig, datadir): ac._evtracker.set_timeout(30) return ac, dict(configdict) - def get_online_configuring_account(self, mvbox=False, sentbox=False, + def get_online_configuring_account(self, mvbox=False, sentbox=False, move=False, pre_generated_key=True, config={}): 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" + configdict["mvbox_move"] = str(int(move)) + configdict["sentbox_watch"] = str(int(sentbox)) ac.update_config(configdict) ac.start() return ac - def get_one_online_account(self, pre_generated_key=True): + def get_one_online_account(self, pre_generated_key=True, mvbox=False, move=False): ac1 = self.get_online_configuring_account( - pre_generated_key=pre_generated_key) + pre_generated_key=pre_generated_key, mvbox=mvbox, move=move) ac1._configtracker.wait_imap_connected() ac1._configtracker.wait_smtp_connected() ac1._configtracker.wait_finish() return ac1 - def get_two_online_accounts(self): - ac1 = self.get_online_configuring_account() + def get_two_online_accounts(self, move=False): + ac1 = self.get_online_configuring_account(move=True) ac2 = self.get_online_configuring_account() ac1._configtracker.wait_finish() ac2._configtracker.wait_finish() diff --git a/python/tests/test_account.py b/python/tests/test_account.py index a714c76b6..1b16238ce 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -497,7 +497,7 @@ class TestOnlineAccount: for x in export_files: assert x.startswith(dir.strpath) ac1._evtracker.consume_events() - ac1.import_self_keys(dir.strpath) + ac2.import_self_keys(dir.strpath) def test_one_account_send_bcc_setting(self, acfactory, lp): ac1 = acfactory.get_online_configuring_account() @@ -607,7 +607,7 @@ class TestOnlineAccount: def test_mvbox_sentbox_threads(self, acfactory, lp): lp.sec("ac1: start with mvbox thread") - ac1 = acfactory.get_online_configuring_account(mvbox=True, sentbox=True) + ac1 = acfactory.get_online_configuring_account(mvbox=True, move=True, sentbox=True) lp.sec("ac2: start without mvbox/sentbox threads") ac2 = acfactory.get_online_configuring_account() @@ -627,7 +627,7 @@ class TestOnlineAccount: def test_move_works(self, acfactory): ac1 = acfactory.get_online_configuring_account() - ac2 = acfactory.get_online_configuring_account(mvbox=True) + ac2 = acfactory.get_online_configuring_account(mvbox=True, move=True) wait_configuration_progress(ac2, 1000) wait_configuration_progress(ac1, 1000) chat = self.get_chat(ac1, ac2) @@ -637,7 +637,7 @@ class TestOnlineAccount: ac2._evtracker.get_matching("DC_EVENT_IMAP_MESSAGE_MOVED") def test_move_works_on_self_sent(self, acfactory): - ac1 = acfactory.get_online_configuring_account(mvbox=True) + ac1 = acfactory.get_online_configuring_account(mvbox=True, move=True) ac1.set_config("bcc_self", "1") ac2 = acfactory.get_online_configuring_account() wait_configuration_progress(ac2, 1000) @@ -708,16 +708,16 @@ class TestOnlineAccount: assert msg_in.is_forwarded() def test_send_self_message_and_empty_folder(self, acfactory, lp): - ac1 = acfactory.get_one_online_account() + ac1 = acfactory.get_one_online_account(mvbox=True, move=True) lp.sec("ac1: create self chat") chat = ac1.create_chat_by_contact(ac1.get_self_contact()) chat.send_text("hello") ac1._evtracker.get_matching("DC_EVENT_SMTP_MESSAGE_SENT") ac1.empty_server_folders(inbox=True, mvbox=True) - ev = ac1._evtracker.get_matching("DC_EVENT_IMAP_FOLDER_EMPTIED") - assert ev.data2 == "DeltaChat" - ev = ac1._evtracker.get_matching("DC_EVENT_IMAP_FOLDER_EMPTIED") - assert ev.data2 == "INBOX" + ev1 = ac1._evtracker.get_matching("DC_EVENT_IMAP_FOLDER_EMPTIED") + ev2 = ac1._evtracker.get_matching("DC_EVENT_IMAP_FOLDER_EMPTIED") + boxes = sorted([ev1.data2, ev2.data2]) + assert boxes == ["DeltaChat", "INBOX"] def test_send_and_receive_message_markseen(self, acfactory, lp): ac1, ac2 = acfactory.get_two_online_accounts() @@ -789,7 +789,7 @@ class TestOnlineAccount: pass # mark_seen_messages() has generated events before it returns def test_mdn_asymetric(self, acfactory, lp): - ac1, ac2 = acfactory.get_two_online_accounts() + ac1, ac2 = acfactory.get_two_online_accounts(move=True) lp.sec("ac1: create chat with ac2") chat = self.get_chat(ac1, ac2, both_created=True) @@ -1477,8 +1477,8 @@ class TestGroupStressTests: class TestOnlineConfigureFails: def test_invalid_password(self, acfactory): ac1, configdict = acfactory.get_online_config() - ac1.configure(addr=configdict["addr"], mail_pw="123") - ac1.start_threads() + ac1.update_config(dict(addr=configdict["addr"], mail_pw="123")) + ac1.start() wait_configuration_progress(ac1, 500) ev = ac1._evtracker.get_matching("DC_EVENT_ERROR_NETWORK") assert "cannot login" in ev.data2.lower() @@ -1486,8 +1486,8 @@ class TestOnlineConfigureFails: def test_invalid_user(self, acfactory): ac1, configdict = acfactory.get_online_config() - ac1.configure(addr="x" + configdict["addr"], mail_pw=configdict["mail_pw"]) - ac1.start_threads() + ac1.update_config(dict(addr="x" + configdict["addr"], mail_pw=configdict["mail_pw"])) + ac1.start() wait_configuration_progress(ac1, 500) ev = ac1._evtracker.get_matching("DC_EVENT_ERROR_NETWORK") assert "cannot login" in ev.data2.lower() @@ -1495,8 +1495,8 @@ class TestOnlineConfigureFails: def test_invalid_domain(self, acfactory): ac1, configdict = acfactory.get_online_config() - ac1.configure(addr=configdict["addr"] + "x", mail_pw=configdict["mail_pw"]) - ac1.start_threads() + ac1.update_config((dict(addr=configdict["addr"] + "x", mail_pw=configdict["mail_pw"]))) + ac1.start() wait_configuration_progress(ac1, 500) ev = ac1._evtracker.get_matching("DC_EVENT_ERROR_NETWORK") assert "could not connect" in ev.data2.lower() diff --git a/python/tests/test_lowlevel.py b/python/tests/test_lowlevel.py index 1a6259a2e..37dfd5625 100644 --- a/python/tests/test_lowlevel.py +++ b/python/tests/test_lowlevel.py @@ -1,7 +1,7 @@ from __future__ import print_function from deltachat import capi, cutil, const, set_context_callback, clear_context_callback from deltachat import register_global_plugin -from deltachat.hookspec import account_hookimpl, global_hookimpl +from deltachat.hookspec import global_hookimpl from deltachat.capi import ffi from deltachat.capi import lib