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):
|
def __init__(self, dc_context, contact_id):
|
||||||
self.dc_context = dc_context
|
self.dc_context = dc_context
|
||||||
self.id = contact_id
|
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)
|
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
|
@property
|
||||||
def addr(self):
|
def addr(self):
|
||||||
return ffi_unicode(capi.lib.dc_contact_get_addr(self.dc_contact_t))
|
return ffi_unicode(capi.lib.dc_contact_get_addr(self.dc_contact_t))
|
||||||
|
@ -161,6 +163,8 @@ class Account:
|
||||||
return ffi_unicode(res)
|
return ffi_unicode(res)
|
||||||
|
|
||||||
def get_self_contact(self):
|
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)
|
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):
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
import pytest
|
||||||
from deltachat.capi import lib
|
from deltachat.capi import lib
|
||||||
|
|
||||||
|
|
||||||
class TestOfflineAccount:
|
class TestOfflineAccount:
|
||||||
def test_selfcontact(self, acfactory):
|
def test_selfcontact_if_unconfigured(self, acfactory):
|
||||||
ac1 = acfactory.get_offline_account()
|
ac1 = acfactory.get_offline_account()
|
||||||
me = ac1.get_self_contact()
|
with pytest.raises(ValueError):
|
||||||
assert me.display_name
|
ac1.get_self_contact()
|
||||||
# assert me.addr # xxx why is this empty?
|
|
||||||
|
|
||||||
def test_contacts(self, acfactory):
|
def test_contacts(self, acfactory):
|
||||||
ac1 = acfactory.get_offline_account()
|
ac1 = acfactory.get_offline_account()
|
||||||
|
@ -50,6 +50,13 @@ class TestOnlineAccount:
|
||||||
print("** CONFIG PROGRESS {}".format(target), account.dc_context)
|
print("** CONFIG PROGRESS {}".format(target), account.dc_context)
|
||||||
break
|
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):
|
def test_basic_configure_login_ok(self, acfactory):
|
||||||
ac1 = acfactory.get_live_account()
|
ac1 = acfactory.get_live_account()
|
||||||
self.wait_successful_IMAP_SMTP_connection(ac1)
|
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_EVENT_INFO == 100
|
||||||
assert capi.lib.DC_CONTACT_ID_SELF
|
assert capi.lib.DC_CONTACT_ID_SELF
|
||||||
|
|
||||||
|
|
||||||
def test_sig():
|
def test_sig():
|
||||||
sig = capi.lib.dc_get_event_signature_types
|
sig = capi.lib.dc_get_event_signature_types
|
||||||
assert sig(capi.lib.DC_EVENT_INFO) == 2
|
assert sig(capi.lib.DC_EVENT_INFO) == 2
|
||||||
|
|
|
@ -2181,7 +2181,7 @@ uint32_t dc_send_text_msg(dc_context_t* context, uint32_t chat_id, const char* t
|
||||||
uint32_t ret = 0;
|
uint32_t ret = 0;
|
||||||
|
|
||||||
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || chat_id<=DC_CHAT_ID_LAST_SPECIAL || text_to_send==NULL) {
|
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || chat_id<=DC_CHAT_ID_LAST_SPECIAL || text_to_send==NULL) {
|
||||||
dc_log_info(context, 0, "some error");
|
dc_log_info(context, 0, "some error");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue