diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index 4799dc87..b37947bc 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -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): diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 781e924d..953f1c91 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -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()