From fcc1fe73be4b72dd3788b01528acb67d4e806a4f Mon Sep 17 00:00:00 2001 From: link2xt Date: Thu, 23 Mar 2023 18:34:54 +0000 Subject: [PATCH] Do not use .wait_for_seen() in test_one_account_send_bcc_setting .wait_for_seen() is unreliable, because sometimes Dovecot sends only EXISTS to the IDLE connection, but not the FETCH. Dovecot sends updates like FETCH only if some connection has already observed the message in previous state without the \Seen flag. To avoid this race condition, wait until the core sets the flag, then FETCH the message manually and check that the flag is set. --- python/tests/test_1_online.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index 412247cbb..1d86e8853 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -134,22 +134,27 @@ def test_one_account_send_bcc_setting(acfactory, lp): ac1.set_config("bcc_self", "1") lp.sec("send out message with bcc to ourselves") - with ac1.direct_imap.idle() as idle1: - msg_out = chat.send_text("message2") + msg_out = chat.send_text("message2") - # wait for send out (BCC) - ev = ac1._evtracker.get_matching("DC_EVENT_SMTP_MESSAGE_SENT") - assert ac1.get_config("bcc_self") == "1" + # wait for send out (BCC) + ev = ac1._evtracker.get_matching("DC_EVENT_SMTP_MESSAGE_SENT") + assert ac1.get_config("bcc_self") == "1" - # now make sure we are sending message to ourselves too - assert self_addr in ev.data2 - assert other_addr in ev.data2 - assert idle1.wait_for_seen() - - # Second client receives only second message, but not the first + # Second client receives only second message, but not the first. ev_msg = ac1_clone._evtracker.wait_next_messages_changed() assert ev_msg.text == msg_out.text + # now make sure we are sending message to ourselves too + assert self_addr in ev.data2 + assert other_addr in ev.data2 + + # BCC-self messages are marked as seen by the sender device. + ac1._evtracker.get_info_contains("Marked messages 1 in folder INBOX as seen.") + + # Check that the message is marked as seen on IMAP. + ac1.direct_imap.select_folder("Inbox") + assert len(list(ac1.direct_imap.conn.fetch(AND(seen=True)))) == 1 + def test_send_file_twice_unicode_filename_mangling(tmpdir, acfactory, lp): ac1, ac2 = acfactory.get_online_accounts(2)