mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-05 10:39:27 +02:00

This uses one global event handler function on the C level, as enforced by CFFI, and caters for registering a per-context event handeler. A simple fixture for doing this during tests is also implemented.
17 lines
501 B
Python
17 lines
501 B
Python
import deltachat
|
|
from deltachat import capi
|
|
|
|
|
|
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_cb(register_dc_callback):
|
|
def cb(ctx, evt, data1, data2):
|
|
return 0
|
|
ctx = capi.lib.dc_context_new(capi.lib.py_dc_callback,
|
|
capi.ffi.NULL, capi.ffi.NULL)
|
|
register_dc_callback(ctx, cb)
|
|
capi.lib.dc_close(ctx)
|
|
assert deltachat._DC_CALLBACK_MAP[ctx] is cb
|