From a244393860ccd2f39900f63ba39be33ef93522ed Mon Sep 17 00:00:00 2001 From: holger krekel Date: Fri, 7 Sep 2018 19:19:31 +0200 Subject: [PATCH] introduce get_config() helper --- python/src/deltachat/account.py | 7 +++++++ python/tests/test_account.py | 6 ++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index 92aa59a0..dfeeee93 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -27,6 +27,8 @@ class EventHandler: def dc_event_http_get(self, data1, data2): url = data1 content = self.read_url(url) + if not isinstance(content, bytes): + content = content.encode("utf8") # we need to return a fresh pointer that the core owns return capi.lib.dupstring_helper(content) @@ -53,6 +55,11 @@ class Account: value = value.encode("utf8") capi.lib.dc_set_config(self.dc_context, name, value) + def get_config(self, name): + name = name.encode("utf8") + res = capi.lib.dc_get_config(self.dc_context, name, b'') + return capi.ffi.string(res).decode("utf8") + def start(self): deltachat.set_context_callback(self.dc_context, self.process_event) capi.lib.dc_configure(self.dc_context) diff --git a/python/tests/test_account.py b/python/tests/test_account.py index f73014e8..30da4e92 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -10,7 +10,7 @@ except ImportError: class TestLive: def test_basic_configure_login_ok(self, acfactory): q = Queue() - acfactory.get_live_account(logcallback=q.put) + ac1 = acfactory.get_live_account(logcallback=q.put) imap_ok = smtp_ok = False while not imap_ok or not smtp_ok: evt_name, data1, data2 = q.get(timeout=5.0) @@ -22,6 +22,4 @@ class TestLive: imap_ok = True if re.match("smtp-login.*ok.", data2.lower()): smtp_ok = True - - def test_message_send_receive(self, acfactory): - pass + assert ac1.get_config("mail_pw")