mirror of
https://github.com/chatmail/core.git
synced 2026-05-12 19:36:32 +03:00
fix #1020 -- allow to set os_name in python bindings
This commit is contained in:
@@ -26,7 +26,7 @@ class Account(object):
|
|||||||
by the underlying deltachat core library. All public Account methods are
|
by the underlying deltachat core library. All public Account methods are
|
||||||
meant to be memory-safe and return memory-safe objects.
|
meant to be memory-safe and return memory-safe objects.
|
||||||
"""
|
"""
|
||||||
def __init__(self, db_path, logid=None, eventlogging=True, debug=True):
|
def __init__(self, db_path, logid=None, eventlogging=True, os_name=None, debug=True):
|
||||||
""" initialize account object.
|
""" initialize account object.
|
||||||
|
|
||||||
:param db_path: a path to the account database. The database
|
:param db_path: a path to the account database. The database
|
||||||
@@ -34,10 +34,11 @@ class Account(object):
|
|||||||
:param logid: an optional logging prefix that should be used with
|
:param logid: an optional logging prefix that should be used with
|
||||||
the default internal logging.
|
the default internal logging.
|
||||||
:param eventlogging: if False no eventlogging and no context callback will be configured
|
:param eventlogging: if False no eventlogging and no context callback will be configured
|
||||||
|
:param os_name: this will be put to the X-Mailer header in outgoing messages
|
||||||
:param debug: turn on debug logging for events.
|
:param debug: turn on debug logging for events.
|
||||||
"""
|
"""
|
||||||
self._dc_context = ffi.gc(
|
self._dc_context = ffi.gc(
|
||||||
lib.dc_context_new(lib.py_dc_callback, ffi.NULL, ffi.NULL),
|
lib.dc_context_new(lib.py_dc_callback, ffi.NULL, as_dc_charpointer(os_name)),
|
||||||
_destroy_dc_context,
|
_destroy_dc_context,
|
||||||
)
|
)
|
||||||
if eventlogging:
|
if eventlogging:
|
||||||
|
|||||||
@@ -16,6 +16,14 @@ class TestOfflineAccountBasic:
|
|||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
Account(p.strpath)
|
Account(p.strpath)
|
||||||
|
|
||||||
|
def test_os_name(self, tmpdir):
|
||||||
|
p = tmpdir.join("hello.db")
|
||||||
|
# we can't easily test if os_name is used in X-Mailer
|
||||||
|
# outgoing messages without a full Online test
|
||||||
|
# but we at least check Account accepts the arg
|
||||||
|
ac1 = Account(p.strpath, os_name="solarpunk")
|
||||||
|
ac1.get_info()
|
||||||
|
|
||||||
def test_getinfo(self, acfactory):
|
def test_getinfo(self, acfactory):
|
||||||
ac1 = acfactory.get_unconfigured_account()
|
ac1 = acfactory.get_unconfigured_account()
|
||||||
d = ac1.get_info()
|
d = ac1.get_info()
|
||||||
|
|||||||
Reference in New Issue
Block a user