mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
remove logid from Account creation, one can now just use the "displayname" for log purposes
This commit is contained in:
@@ -26,15 +26,15 @@ def test_echo_quit_plugin(acfactory, lp):
|
|||||||
|
|
||||||
lp.sec("sending a message to the bot")
|
lp.sec("sending a message to the bot")
|
||||||
bot_contact = ac1.create_contact(botproc.addr)
|
bot_contact = ac1.create_contact(botproc.addr)
|
||||||
ch1 = bot_contact.create_chat()
|
bot_chat = bot_contact.create_chat()
|
||||||
ch1.send_text("hello")
|
bot_chat.send_text("hello")
|
||||||
|
|
||||||
lp.sec("waiting for the bot-reply to arrive")
|
lp.sec("waiting for the reply message from the bot to arrive")
|
||||||
reply = ac1._evtracker.wait_next_incoming_message()
|
reply = ac1._evtracker.wait_next_incoming_message()
|
||||||
|
assert reply.chat == bot_chat
|
||||||
assert "hello" in reply.text
|
assert "hello" in reply.text
|
||||||
assert reply.chat == ch1
|
|
||||||
lp.sec("send quit sequence")
|
lp.sec("send quit sequence")
|
||||||
ch1.send_text("/quit")
|
bot_chat.send_text("/quit")
|
||||||
botproc.wait()
|
botproc.wait()
|
||||||
|
|
||||||
|
|
||||||
@@ -47,8 +47,8 @@ def test_group_tracking_plugin(acfactory, lp):
|
|||||||
botproc.fnmatch_lines("""
|
botproc.fnmatch_lines("""
|
||||||
*ac_configure_completed*
|
*ac_configure_completed*
|
||||||
""")
|
""")
|
||||||
ac1.add_account_plugin(FFIEventLogger(ac1, "ac1"))
|
ac1.add_account_plugin(FFIEventLogger(ac1))
|
||||||
ac2.add_account_plugin(FFIEventLogger(ac2, "ac2"))
|
ac2.add_account_plugin(FFIEventLogger(ac2))
|
||||||
|
|
||||||
lp.sec("creating bot test group with bot")
|
lp.sec("creating bot test group with bot")
|
||||||
bot_contact = ac1.create_contact(botproc.addr)
|
bot_contact = ac1.create_contact(botproc.addr)
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ def run_cmdline(argv=None, account_plugins=None):
|
|||||||
ac = Account(args.db)
|
ac = Account(args.db)
|
||||||
|
|
||||||
if args.show_ffi:
|
if args.show_ffi:
|
||||||
log = events.FFIEventLogger(ac, "bot")
|
ac.set_config("displayname", "bot")
|
||||||
|
log = events.FFIEventLogger(ac)
|
||||||
ac.add_account_plugin(log)
|
ac.add_account_plugin(log)
|
||||||
|
|
||||||
for plugin in account_plugins or []:
|
for plugin in account_plugins or []:
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class Account(object):
|
|||||||
"""
|
"""
|
||||||
MissingCredentials = MissingCredentials
|
MissingCredentials = MissingCredentials
|
||||||
|
|
||||||
def __init__(self, db_path, os_name=None, logging=True, logid=None):
|
def __init__(self, db_path, os_name=None, logging=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
|
||||||
@@ -38,7 +38,6 @@ class Account(object):
|
|||||||
# initialize per-account plugin system
|
# initialize per-account plugin system
|
||||||
self._pm = hookspec.PerAccount._make_plugin_manager()
|
self._pm = hookspec.PerAccount._make_plugin_manager()
|
||||||
self._logging = logging
|
self._logging = logging
|
||||||
self.logid = logid
|
|
||||||
|
|
||||||
self.add_account_plugin(self)
|
self.add_account_plugin(self)
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ def dc_account_extra_configure(account):
|
|||||||
""" Reset the account (we reuse accounts across tests)
|
""" Reset the account (we reuse accounts across tests)
|
||||||
and make 'account.direct_imap' available for direct IMAP ops.
|
and make 'account.direct_imap' available for direct IMAP ops.
|
||||||
"""
|
"""
|
||||||
imap = DirectImap(account, account.logid)
|
imap = DirectImap(account)
|
||||||
if imap.select_config_folder("mvbox"):
|
if imap.select_config_folder("mvbox"):
|
||||||
imap.delete(ALL, expunge=True)
|
imap.delete(ALL, expunge=True)
|
||||||
assert imap.select_config_folder("inbox")
|
assert imap.select_config_folder("inbox")
|
||||||
@@ -42,9 +42,9 @@ def dc_account_after_shutdown(account):
|
|||||||
|
|
||||||
|
|
||||||
class DirectImap:
|
class DirectImap:
|
||||||
def __init__(self, account, logid):
|
def __init__(self, account):
|
||||||
self.account = account
|
self.account = account
|
||||||
self.logid = logid
|
self.logid = account.get_config("displayname") or id(account)
|
||||||
self._idling = False
|
self._idling = False
|
||||||
self.connect()
|
self.connect()
|
||||||
|
|
||||||
|
|||||||
@@ -28,13 +28,9 @@ class FFIEventLogger:
|
|||||||
# to prevent garbled logging
|
# to prevent garbled logging
|
||||||
_loglock = threading.RLock()
|
_loglock = threading.RLock()
|
||||||
|
|
||||||
def __init__(self, account, logid):
|
def __init__(self, account):
|
||||||
"""
|
|
||||||
:param logid: an optional logging prefix that should be used with
|
|
||||||
the default internal logging.
|
|
||||||
"""
|
|
||||||
self.account = account
|
self.account = account
|
||||||
self.logid = logid
|
self.logid = self.account.get_config("displayname")
|
||||||
self.init_time = time.time()
|
self.init_time = time.time()
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
|
|||||||
@@ -229,11 +229,12 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig, data):
|
|||||||
deltachat.unregister_global_plugin(direct_imap)
|
deltachat.unregister_global_plugin(direct_imap)
|
||||||
|
|
||||||
def make_account(self, path, logid, quiet=False):
|
def make_account(self, path, logid, quiet=False):
|
||||||
ac = Account(path, logging=self._logging, logid=logid)
|
ac = Account(path, logging=self._logging)
|
||||||
ac._evtracker = ac.add_account_plugin(FFIEventTracker(ac))
|
ac._evtracker = ac.add_account_plugin(FFIEventTracker(ac))
|
||||||
ac.addr = ac.get_self_contact().addr
|
ac.addr = ac.get_self_contact().addr
|
||||||
|
ac.set_config("displayname", logid)
|
||||||
if not quiet:
|
if not quiet:
|
||||||
ac.add_account_plugin(FFIEventLogger(ac, logid=logid))
|
ac.add_account_plugin(FFIEventLogger(ac))
|
||||||
self._accounts.append(ac)
|
self._accounts.append(ac)
|
||||||
return ac
|
return ac
|
||||||
|
|
||||||
@@ -321,12 +322,16 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig, data):
|
|||||||
ac2.start_io()
|
ac2.start_io()
|
||||||
return ac1, ac2
|
return ac1, ac2
|
||||||
|
|
||||||
def get_many_online_accounts(self, num, move=True, quiet=True):
|
def get_many_online_accounts(self, num, move=True):
|
||||||
accounts = [self.get_online_configuring_account(move=move, quiet=quiet)
|
accounts = [self.get_online_configuring_account(move=move, quiet=True)
|
||||||
for i in range(num)]
|
for i in range(num)]
|
||||||
for acc in accounts:
|
for acc in accounts:
|
||||||
acc._configtracker.wait_finish()
|
acc._configtracker.wait_finish()
|
||||||
acc.start_io()
|
acc.start_io()
|
||||||
|
print("{}: {} account was successfully setup".format(
|
||||||
|
acc.get_config("displayname"), acc.get_config("addr")))
|
||||||
|
for acc in accounts:
|
||||||
|
acc.add_account_plugin(FFIEventLogger(acc))
|
||||||
return accounts
|
return accounts
|
||||||
|
|
||||||
def clone_online_account(self, account, pre_generated_key=True):
|
def clone_online_account(self, account, pre_generated_key=True):
|
||||||
|
|||||||
Reference in New Issue
Block a user