mirror of
https://github.com/chatmail/core.git
synced 2026-04-05 23:22:11 +03:00
strike setting "displayname" in test plugin and refine two tests which implicitely relied on this
This commit is contained in:
@@ -29,9 +29,9 @@ class FFIEventLogger:
|
||||
# to prevent garbled logging
|
||||
_loglock = threading.RLock()
|
||||
|
||||
def __init__(self, account, init_time=None) -> None:
|
||||
def __init__(self, account, logid=None, init_time=None) -> None:
|
||||
self.account = account
|
||||
self.logid = self.account.get_config("displayname")
|
||||
self.logid = logid or self.account.get_config("displayname")
|
||||
if init_time is None:
|
||||
init_time = time.time()
|
||||
self.init_time = init_time
|
||||
|
||||
@@ -254,6 +254,7 @@ class ACFactory:
|
||||
logid = "ac{}".format(len(self._accounts) + 1)
|
||||
path = self.tmpdir.join(logid)
|
||||
ac = Account(path.strpath, logging=self._logging)
|
||||
ac._logid = logid # later instantiated FFIEventLogger needs this
|
||||
ac._evtracker = ac.add_account_plugin(FFIEventTracker(ac))
|
||||
self._accounts.append(ac)
|
||||
return ac
|
||||
@@ -305,7 +306,6 @@ class ACFactory:
|
||||
configdict.setdefault("bcc_self", False)
|
||||
configdict.setdefault("mvbox_move", False)
|
||||
configdict.setdefault("sentbox_watch", False)
|
||||
configdict.setdefault("displayname", os.path.basename(ac.db_path))
|
||||
ac.update_config(configdict)
|
||||
self._preconfigure_key(ac, configdict["addr"])
|
||||
return ac
|
||||
@@ -331,14 +331,13 @@ class ACFactory:
|
||||
assert logstart in ("after_inbox_idle_ready",), logstart
|
||||
|
||||
for acc in self._accounts:
|
||||
logger = FFIEventLogger(acc, init_time=self.init_time)
|
||||
logger = FFIEventLogger(acc, logid=acc._logid, init_time=self.init_time)
|
||||
self.wait_configure(acc)
|
||||
acc.start_io()
|
||||
print("{}: {} waiting for inbox idle to become ready".format(
|
||||
acc.get_config("displayname"), acc.get_config("addr")))
|
||||
acc.log("waiting for inbox IDLE to become ready")
|
||||
acc._evtracker.wait_idle_inbox_ready()
|
||||
print("{}: {} account IMAP IO ready to receive".format(
|
||||
acc.get_config("displayname"), acc.get_config("addr")))
|
||||
print("account IDLE: ready")
|
||||
assert 0
|
||||
if logstart == "after_inbox_idle_ready":
|
||||
acc.add_account_plugin(logger)
|
||||
|
||||
|
||||
@@ -1145,11 +1145,10 @@ class TestOnlineAccount:
|
||||
|
||||
def test_message_override_sender_name(self, acfactory, lp):
|
||||
ac1, ac2 = acfactory.get_online_accounts(2)
|
||||
ac1.set_config("displayname", "ac1-default-displayname")
|
||||
chat = acfactory.get_accepted_chat(ac1, ac2)
|
||||
overridden_name = "someone else"
|
||||
|
||||
ac1.set_config("displayname", "ac1")
|
||||
|
||||
lp.sec("sending text message with overridden name from ac1 to ac2")
|
||||
msg1 = Message.new_empty(ac1, "text")
|
||||
msg1.set_override_sender_name(overridden_name)
|
||||
@@ -1160,7 +1159,9 @@ class TestOnlineAccount:
|
||||
lp.sec("wait for ac2 to receive message")
|
||||
msg2 = ac2._evtracker.wait_next_incoming_message()
|
||||
assert msg2.text == "message1"
|
||||
assert msg2.get_sender_contact().name == ac1.get_config("displayname")
|
||||
sender = msg2.get_sender_contact()
|
||||
assert sender.addr == ac1.get_config("addr")
|
||||
assert sender.name == ac1.get_config("displayname")
|
||||
assert msg2.override_sender_name == overridden_name
|
||||
|
||||
lp.sec("sending normal text message from ac1 to ac2")
|
||||
@@ -2846,7 +2847,8 @@ class TestOnlineAccount:
|
||||
lp.sec("send out message with bcc to ourselves")
|
||||
ac1.direct_imap.idle_start()
|
||||
ac1.set_config("bcc_self", "1")
|
||||
ac1.create_chat(ac2).send_text("outgoing, encrypted direct message, creating a chat")
|
||||
ac1_ac2_chat = ac1.create_chat(ac2)
|
||||
ac1_ac2_chat.send_text("outgoing, encrypted direct message, creating a chat")
|
||||
|
||||
# now wait until the bcc_self message arrives
|
||||
assert ac1.direct_imap.idle_wait_for_seen()
|
||||
@@ -2858,11 +2860,12 @@ class TestOnlineAccount:
|
||||
|
||||
ac1_clone.start_io()
|
||||
ac1_clone._evtracker.wait_idle_inbox_ready()
|
||||
|
||||
chats = ac1_clone.get_chats()
|
||||
assert len(chats) == 4 # two newly created chats + self-chat + device-chat
|
||||
group_chat = [c for c in chats if c.get_name() == "group name"][0]
|
||||
assert group_chat.is_group()
|
||||
private_chat = [c for c in chats if c.get_name() == "ac2"][0]
|
||||
private_chat, = [c for c in chats if c.get_name() == ac1_ac2_chat.get_name()]
|
||||
assert not private_chat.is_group()
|
||||
|
||||
group_messages = group_chat.get_messages()
|
||||
|
||||
Reference in New Issue
Block a user