diff --git a/python/src/deltachat/testplugin.py b/python/src/deltachat/testplugin.py index c07a8d518..3c767142b 100644 --- a/python/src/deltachat/testplugin.py +++ b/python/src/deltachat/testplugin.py @@ -473,16 +473,30 @@ class ACFactory: self._acsetup.init_logging(ac) return ac - def new_online_configuring_account(self, cloned_from=None, cache=False, **kwargs): - if cloned_from is None: - configdict = self.get_next_liveconfig() - else: - # XXX we might want to transfer the key to the new account - configdict = dict( - addr=cloned_from.get_config("addr"), - mail_pw=cloned_from.get_config("mail_pw"), - ) + def new_online_configuring_account(self, cache=False, **kwargs): + configdict = self.get_next_liveconfig() configdict.update(kwargs) + return self._setup_online_configuring_account(configdict) + + def get_online_second_device(self, ac1): + ac1 = self._get_cached_account(addr=ac1.get_config("addr")) + self.bring_accounts_online() + return ac1 + + def get_online_multidevice_setup(self, copied=True): + ac1 = self.get_online_accounts(1) + if copied: + ac2 = self._get_cached_account(addr=ac1.get_config("addr")) + else: + configdict = dict(addr=ac1.get_config("addr"), mail_pw=ac1.get_config("mail_pw")) + ac2 = self._setup_online_configuring_account(configdict, cache=False) + self.bring_accounts_online() + return ac1, ac2 + + def get_online_devnull_email(self): + return self.get_next_liveconfig()["addr"] + + def _setup_online_configuring_account(self, configdict, cache=False): ac = self._get_cached_account(addr=configdict["addr"]) if cache else None if ac is not None: # make sure we consume a preconfig key, as if we had created a fresh account diff --git a/python/tests/test_0_complex_or_slow.py b/python/tests/test_0_complex_or_slow.py index e1523da06..c63ee3896 100644 --- a/python/tests/test_0_complex_or_slow.py +++ b/python/tests/test_0_complex_or_slow.py @@ -220,10 +220,7 @@ def test_fetch_existing(acfactory, lp, mvbox_move): assert_folders_configured(ac1) lp.sec("create a cloned ac1 and fetch contact history during configure") - ac1_clone = acfactory.new_online_configuring_account(cloned_from=ac1) - ac1_clone.set_config("fetch_existing_msgs", "1") - acfactory.wait_configured(ac1_clone) - ac1_clone.start_io() + ac1_clone = acfactory.get_online_second_device(fetch_existing_msgs=1) assert_folders_configured(ac1_clone) lp.sec("check that ac2 contact was fetchted during configure") @@ -266,12 +263,7 @@ def test_fetch_existing_msgs_group_and_single(acfactory, lp): assert idle1.wait_for_seen() lp.sec("Clone online account and let it fetch the existing messages") - ac1_clone = acfactory.new_online_configuring_account(cloned_from=ac1) - ac1_clone.set_config("fetch_existing_msgs", "1") - acfactory.wait_configured(ac1_clone) - - ac1_clone.start_io() - ac1_clone._evtracker.wait_idle_inbox_ready() + ac1_clone = acfactory.get_online_second_device(fetch_existing_msgs=1) chats = ac1_clone.get_chats() assert len(chats) == 4 # two newly created chats + self-chat + device-chat @@ -307,13 +299,8 @@ def test_undecipherable_group(acfactory, lp): lp.sec("ac3 reinstalls DC and generates a new key") ac3.stop_io() acfactory.remove_preconfigured_keys() - ac4 = acfactory.new_online_configuring_account(cloned_from=ac3) - acfactory.wait_configured(ac4) + ac4 = acfactory.get_online_second_device(ac3) # Create contacts to make sure incoming messages are not treated as contact requests - chat41 = ac4.create_chat(ac1) - chat42 = ac4.create_chat(ac2) - ac4.start_io() - ac4._evtracker.wait_idle_inbox_ready() lp.sec("ac1: creating group chat with 2 other members") chat = ac1.create_group_chat("title", contacts=[ac2, ac3]) @@ -426,10 +413,7 @@ def test_ephemeral_timer(acfactory, lp): def test_multidevice_sync_seen(acfactory, lp): """Test that message marked as seen on one device is marked as seen on another.""" - ac1 = acfactory.new_online_configuring_account() - ac2 = acfactory.new_online_configuring_account() - ac1_clone = acfactory.new_online_configuring_account(cloned_from=ac1) - acfactory.bring_accounts_online() + ac1, ac2 = acfactory.get_online_multidevice_setup() ac1.set_config("bcc_self", "1") ac1_clone.set_config("bcc_self", "1") diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index 7d19ec57d..8844054a6 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -92,16 +92,13 @@ def test_export_import_self_keys(acfactory, tmpdir, lp): def test_one_account_send_bcc_setting(acfactory, lp): - ac1 = acfactory.new_online_configuring_account() - ac2 = acfactory.new_online_configuring_account() - ac1_clone = acfactory.new_online_configuring_account(cloned_from=ac1) - acfactory.bring_accounts_online() + ac1, ac1_clone = acfactory.get_online_multidevice_setup() # test if sent messages are copied to it via BCC. chat = acfactory.get_accepted_chat(ac1, ac2) self_addr = ac1.get_config("addr") - other_addr = ac2.get_config("addr") + other_addr = acfactory.get_online_devnull_email() lp.sec("send out message without bcc to ourselves") ac1.set_config("bcc_self", "0") @@ -863,14 +860,12 @@ def test_dont_show_emails(acfactory, lp): def test_no_old_msg_is_fresh(acfactory, lp): - ac1 = acfactory.new_online_configuring_account() - ac2 = acfactory.new_online_configuring_account() - ac1_clone = acfactory.new_online_configuring_account(cloned_from=ac1) - acfactory.bring_accounts_online() + ac1, ac1_clone = acfactory.get_online_multidevice_setup() + ac2 = acfactory.get_online_accounts(1) - ac1.set_config("e2ee_enabled", "0") - ac1_clone.set_config("e2ee_enabled", "0") - ac2.set_config("e2ee_enabled", "0") + #ac1.set_config("e2ee_enabled", "0") + #ac1_clone.set_config("e2ee_enabled", "0") + #ac2.set_config("e2ee_enabled", "0") ac1_clone.set_config("bcc_self", "1") @@ -1239,9 +1234,7 @@ def test_ac_setup_message(acfactory, lp): # note that the receiving account needs to be configured and running # before ther setup message is send. DC does not read old messages # as of Jul2019 - ac1 = acfactory.new_online_configuring_account() - ac2 = acfactory.new_online_configuring_account(cloned_from=ac1) - acfactory.bring_accounts_online() + ac1, ac2 = acfactory.get_online_multidevice_setup(copied=False) lp.sec("trigger ac setup message and return setupcode") assert ac1.get_info()["fingerprint"] != ac2.get_info()["fingerprint"] @@ -1261,9 +1254,7 @@ def test_ac_setup_message(acfactory, lp): def test_ac_setup_message_twice(acfactory, lp): - ac1 = acfactory.new_online_configuring_account() - ac2 = acfactory.new_online_configuring_account(cloned_from=ac1) - acfactory.bring_accounts_online() + ac1, ac2 = acfactory.get_online_multidevice_setup(copied=False) lp.sec("trigger ac setup message but ignore") assert ac1.get_info()["fingerprint"] != ac2.get_info()["fingerprint"]