From 87365e4a431857ae951d91bc2f69a2caf22b480a Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 1 May 2022 09:35:20 +0200 Subject: [PATCH] - remove superflous early set_configs to separate config / account making better - avoid low-level dc_* API access from testplugin --- python/src/deltachat/testplugin.py | 18 ++++++++---------- python/tests/test_account.py | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/python/src/deltachat/testplugin.py b/python/src/deltachat/testplugin.py index c4e528341..0640679ab 100644 --- a/python/src/deltachat/testplugin.py +++ b/python/src/deltachat/testplugin.py @@ -15,7 +15,6 @@ import pytest import requests from . import Account, const -from .capi import lib from .events import FFIEventLogger, FFIEventTracker from _pytest._code import Source from deltachat import direct_imap @@ -237,9 +236,6 @@ class ACFactory: path = self.tmpdir.join(logid) ac = Account(path.strpath, logging=self._logging) ac._evtracker = ac.add_account_plugin(FFIEventTracker(ac)) - ac.addr = ac.get_self_contact().addr - ac.set_config("displayname", logid) - logger = FFIEventLogger(ac) logger.init_time = self.init_time ac.add_account_plugin(logger) @@ -275,13 +271,14 @@ class ACFactory: ac = self.get_unconfigured_account() # do a pseudo-configured account - addr = "{}@offline.org".format(ac.get_config("displayname")) - ac.set_config("addr", addr) + acname = os.path.basename(ac.db_path) + addr = "{}@offline.org".format(acname) + ac.update_config(dict( + addr=addr, displayname=acname, mail_pw="123", + configured_addr=addr, configured_mail_pw="123", + configured="1", + )) self._preconfigure_key(ac, addr) - lib.dc_set_config(ac._dc_context, b"configured_addr", addr.encode("ascii")) - ac.set_config("mail_pw", "123") - lib.dc_set_config(ac._dc_context, b"configured_mail_pw", b"123") - lib.dc_set_config(ac._dc_context, b"configured", b"1") return ac def get_online_config(self, quiet=False): @@ -298,6 +295,7 @@ class ACFactory: configdict["smtp_certificate_checks"] = str(const.DC_CERTCK_STRICT) ac = self.make_account() + configdict["displayname"] = os.path.basename(ac.db_path) self._preconfigure_key(ac, configdict["addr"]) return ac, dict(configdict) diff --git a/python/tests/test_account.py b/python/tests/test_account.py index fcaf0a890..a4ea8a999 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -2930,7 +2930,7 @@ class TestGroupStressTests: lp.sec("ac2: receiving system message about contact addition") sysmsg = ac2._evtracker.wait_next_incoming_message() - assert ac5.addr in sysmsg.text + assert ac5.get_config("configured_addr") in sysmsg.text assert sysmsg.chat.num_contacts() == 4 lp.sec("ac5: waiting for message about addition to the chat")