diff --git a/python/conftest.py b/python/conftest.py index aee13b11..09817b6b 100644 --- a/python/conftest.py +++ b/python/conftest.py @@ -28,13 +28,21 @@ def acfactory(pytestconfig, tmpdir, request): name, value = part.split("=") d[name] = value self.configlist.append(d) - self.count = 0 + self.live_count = 0 + self.offline_count = 0 + + def get_offline_account(self): + self.offline_count += 1 + tmpdb = tmpdir.join("offlinedb%d" % self.offline_count) + ac = Account(tmpdb.strpath, _logid="ac{}".format(self.offline_count)) + ac._evlogger.set_timeout(2) + return ac def get_live_account(self, started=True): + self.live_count += 1 configdict = self.configlist.pop(0) - tmpdb = tmpdir.join("testdb%d" % self.count) - ac = Account(tmpdb.strpath, _logid="ac{}".format(self.count+1)) - self.count += 1 + tmpdb = tmpdir.join("livedb%d" % self.live_count) + ac = Account(tmpdb.strpath, _logid="ac{}".format(self.live_count)) ac._evlogger.set_timeout(10) ac.set_config(**configdict) if started: diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 1d82fc30..1f49ff8a 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -3,16 +3,15 @@ import time from deltachat.capi import lib -class TestLive: - +class TestOfflineAccount: def test_selfcontact(self, acfactory): - ac1 = acfactory.get_live_account(started=False) + ac1 = acfactory.get_offline_account() me = ac1.get_self_contact() assert me.display_name # assert me.addr # xxx why is this empty? def test_contacts(self, acfactory): - ac1 = acfactory.get_live_account(started=False) + ac1 = acfactory.get_offline_account() contact1 = ac1.create_contact(email="some1@hello.com", name="some1") assert contact1.id assert contact1.addr == "some1@hello.com" @@ -21,11 +20,13 @@ class TestLive: assert not contact1.is_verified def test_chat(self, acfactory): - ac1 = acfactory.get_live_account(started=False) + ac1 = acfactory.get_offline_account() contact1 = ac1.create_contact("some1@hello.com", name="some1") chat = ac1.create_chat_by_contact(contact1) assert chat.id + +class TestOnlineAccount: def wait_successful_IMAP_SMTP_connection(self, account): imap_ok = smtp_ok = False while not imap_ok or not smtp_ok: