mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-04 10:19:16 +02:00
add account.is_configured() method and assert helper
This commit is contained in:
parent
a65abba4f0
commit
41e3bb3aaa
2 changed files with 15 additions and 2 deletions
|
@ -175,9 +175,15 @@ class Account(object):
|
||||||
res = capi.lib.dc_get_config(self.dc_context, name, b'')
|
res = capi.lib.dc_get_config(self.dc_context, name, b'')
|
||||||
return ffi_unicode(res)
|
return ffi_unicode(res)
|
||||||
|
|
||||||
def get_self_contact(self):
|
def is_configured(self):
|
||||||
if not capi.lib.dc_is_configured(self.dc_context):
|
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")
|
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)
|
return Contact(self.dc_context, capi.lib.DC_CONTACT_ID_SELF)
|
||||||
|
|
||||||
def create_contact(self, email, name=ffi.NULL):
|
def create_contact(self, email, name=ffi.NULL):
|
||||||
|
|
|
@ -4,6 +4,12 @@ from deltachat.capi import lib
|
||||||
|
|
||||||
|
|
||||||
class TestOfflineAccount:
|
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):
|
def test_selfcontact_if_unconfigured(self, acfactory):
|
||||||
ac1 = acfactory.get_offline_account()
|
ac1 = acfactory.get_offline_account()
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
|
@ -70,6 +76,7 @@ class TestOnlineAccount:
|
||||||
self.wait_successful_IMAP_SMTP_connection(ac1)
|
self.wait_successful_IMAP_SMTP_connection(ac1)
|
||||||
self.wait_configuration_progress(ac1, 1000)
|
self.wait_configuration_progress(ac1, 1000)
|
||||||
assert ac1.get_config("mail_pw")
|
assert ac1.get_config("mail_pw")
|
||||||
|
assert ac1.is_configured()
|
||||||
|
|
||||||
def test_send_message(self, acfactory):
|
def test_send_message(self, acfactory):
|
||||||
ac1 = acfactory.get_live_account()
|
ac1 = acfactory.get_live_account()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue