mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
wip try test that we see INFO events from the core
This commit is contained in:
@@ -20,6 +20,7 @@ def py_dc_callback(ctx, evt, data1, data2):
|
||||
CFFI only allows us to set one global event handler, so this one
|
||||
looks up the correct event handler for the given context.
|
||||
"""
|
||||
print("py_dc_callback", evt, data1, data2, ctx)
|
||||
try:
|
||||
callback = _DC_CALLBACK_MAP.get(ctx, lambda *a: 0)
|
||||
except AttributeError:
|
||||
@@ -54,6 +55,7 @@ def py_dc_callback(ctx, evt, data1, data2):
|
||||
|
||||
|
||||
def set_context_callback(dc_context, func):
|
||||
print("set_context_callback", dc_context, func)
|
||||
_DC_CALLBACK_MAP[dc_context] = func
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
from __future__ import print_function
|
||||
import pytest
|
||||
from deltachat import capi, Account, const
|
||||
from deltachat import capi, Account, const, set_context_callback
|
||||
from deltachat.cutil import as_dc_charpointer
|
||||
from queue import Queue
|
||||
|
||||
|
||||
def test_empty_context():
|
||||
ctx = capi.lib.dc_context_new(capi.ffi.NULL, capi.ffi.NULL, capi.ffi.NULL)
|
||||
capi.lib.dc_close(ctx)
|
||||
|
||||
def test_set_context():
|
||||
ctx = capi.lib.dc_context_new(capi.ffi.NULL, capi.ffi.NULL, capi.ffi.NULL)
|
||||
|
||||
q = Queue()
|
||||
set_context_callback(ctx, lambda *args: q.put(args))
|
||||
|
||||
name = as_dc_charpointer("ein")
|
||||
email = as_dc_charpointer("ein@kontakt.org")
|
||||
contact_id = capi.lib.dc_create_contact(ctx, name, email)
|
||||
capi.lib.dc_close(ctx)
|
||||
q.get(timeout=10)
|
||||
|
||||
|
||||
def test_wrong_db(tmpdir):
|
||||
tmpdir.join("hello.db").write("123")
|
||||
|
||||
Reference in New Issue
Block a user