mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-04 10:19:16 +02:00
address the remaining comments
This commit is contained in:
parent
75153289ef
commit
49040f4e92
4 changed files with 18 additions and 6 deletions
|
@ -79,9 +79,11 @@ class Contact:
|
|||
def __init__(self, dc_context, contact_id):
|
||||
self.dc_context = dc_context
|
||||
self.id = contact_id
|
||||
# XXX do we need to free dc_contact_t? (we own it according to API)
|
||||
self.dc_contact_t = capi.lib.dc_get_contact(self.dc_context, contact_id)
|
||||
|
||||
def __del__(self):
|
||||
capi.lib.free(self.dc_contact_t)
|
||||
|
||||
@property
|
||||
def addr(self):
|
||||
return ffi_unicode(capi.lib.dc_contact_get_addr(self.dc_contact_t))
|
||||
|
@ -161,6 +163,8 @@ class Account:
|
|||
return ffi_unicode(res)
|
||||
|
||||
def get_self_contact(self):
|
||||
if not capi.lib.dc_is_configured(self.dc_context):
|
||||
raise ValueError("need to configure first")
|
||||
return Contact(self.dc_context, capi.lib.DC_CONTACT_ID_SELF)
|
||||
|
||||
def create_contact(self, email, name=ffi.NULL):
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
from __future__ import print_function
|
||||
import pytest
|
||||
from deltachat.capi import lib
|
||||
|
||||
|
||||
class TestOfflineAccount:
|
||||
def test_selfcontact(self, acfactory):
|
||||
def test_selfcontact_if_unconfigured(self, acfactory):
|
||||
ac1 = acfactory.get_offline_account()
|
||||
me = ac1.get_self_contact()
|
||||
assert me.display_name
|
||||
# assert me.addr # xxx why is this empty?
|
||||
with pytest.raises(ValueError):
|
||||
ac1.get_self_contact()
|
||||
|
||||
def test_contacts(self, acfactory):
|
||||
ac1 = acfactory.get_offline_account()
|
||||
|
@ -50,6 +50,13 @@ class TestOnlineAccount:
|
|||
print("** CONFIG PROGRESS {}".format(target), account.dc_context)
|
||||
break
|
||||
|
||||
def test_selfcontact(self, acfactory):
|
||||
ac1 = acfactory.get_live_account()
|
||||
self.wait_configuration_progress(ac1, 1000)
|
||||
me = ac1.get_self_contact()
|
||||
assert me.display_name
|
||||
assert me.addr
|
||||
|
||||
def test_basic_configure_login_ok(self, acfactory):
|
||||
ac1 = acfactory.get_live_account()
|
||||
self.wait_successful_IMAP_SMTP_connection(ac1)
|
||||
|
|
|
@ -11,6 +11,7 @@ def test_event_defines():
|
|||
assert capi.lib.DC_EVENT_INFO == 100
|
||||
assert capi.lib.DC_CONTACT_ID_SELF
|
||||
|
||||
|
||||
def test_sig():
|
||||
sig = capi.lib.dc_get_event_signature_types
|
||||
assert sig(capi.lib.DC_EVENT_INFO) == 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue