1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-04 18:29:19 +02:00

add account.is_configured() method and assert helper

This commit is contained in:
holger krekel 2018-09-13 13:21:21 +02:00
parent a65abba4f0
commit 41e3bb3aaa
2 changed files with 15 additions and 2 deletions

View file

@ -175,9 +175,15 @@ class Account(object):
res = capi.lib.dc_get_config(self.dc_context, name, b'')
return ffi_unicode(res)
def get_self_contact(self):
if not capi.lib.dc_is_configured(self.dc_context):
def is_configured(self):
return capi.lib.dc_is_configured(self.dc_context)
def check_is_configured(self):
if not self.is_configured():
raise ValueError("need to configure first")
def get_self_contact(self):
self.check_is_configured()
return Contact(self.dc_context, capi.lib.DC_CONTACT_ID_SELF)
def create_contact(self, email, name=ffi.NULL):

View file

@ -4,6 +4,12 @@ from deltachat.capi import lib
class TestOfflineAccount:
def test_is_not_configured(self, acfactory):
ac1 = acfactory.get_offline_account()
assert not ac1.is_configured()
with pytest.raises(ValueError):
ac1.check_is_configured()
def test_selfcontact_if_unconfigured(self, acfactory):
ac1 = acfactory.get_offline_account()
with pytest.raises(ValueError):
@ -70,6 +76,7 @@ class TestOnlineAccount:
self.wait_successful_IMAP_SMTP_connection(ac1)
self.wait_configuration_progress(ac1, 1000)
assert ac1.get_config("mail_pw")
assert ac1.is_configured()
def test_send_message(self, acfactory):
ac1 = acfactory.get_live_account()