From b6cc44a9567f251e82b0a45bd50024bf5554b4ba Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 8 Jun 2020 13:42:39 +0200 Subject: [PATCH] integrate direct imap test in existing BCC test --- python/src/deltachat/direct_imap.py | 13 ++++++++++++- python/tests/test_account.py | 2 ++ python/tests/test_direct_imap.py | 21 ++------------------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/python/src/deltachat/direct_imap.py b/python/src/deltachat/direct_imap.py index e53317d80..83a561cdf 100644 --- a/python/src/deltachat/direct_imap.py +++ b/python/src/deltachat/direct_imap.py @@ -176,7 +176,7 @@ class DirectImap: print(stream.getvalue(), file=logfile) - def idle(self): + def idle_start(self): """ switch this connection to idle mode. non-blocking. """ assert not self._idling res = self.conn.idle() @@ -192,6 +192,17 @@ class DirectImap: self.idle_done() return res + def idle_wait_for_seen(self): + """ Return first message with SEEN flag + from a running idle-stream REtiurn. + """ + while 1: + for item in self.idle_check(): + if item[1] == FETCH: + if item[2][0] == FLAGS: + if SEEN in item[2][1]: + return item[0] + def idle_done(self): """ send idle-done to server if we are currently in idle mode. """ if self._idling: diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 4fb89cc11..144cb0004 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -613,6 +613,7 @@ class TestOnlineAccount: ac1.set_config("bcc_self", "1") lp.sec("send out message with bcc to ourselves") + ac1.direct_imap.idle_start() msg_out = chat.send_text("message2") # wait for send out (BCC) @@ -623,6 +624,7 @@ class TestOnlineAccount: assert self_addr in ev.data2 assert other_addr in ev.data2 ev = ac1._evtracker.get_matching("DC_EVENT_DELETED_BLOB_FILE") + assert ac1.direct_imap.idle_wait_for_seen() # Second client receives only second message, but not the first ev_msg = ac1_clone._evtracker.wait_next_messages_changed() diff --git a/python/tests/test_direct_imap.py b/python/tests/test_direct_imap.py index e301847e3..a391d7b06 100644 --- a/python/tests/test_direct_imap.py +++ b/python/tests/test_direct_imap.py @@ -9,7 +9,7 @@ def test_basic_imap_api(acfactory, tmpdir): imap2 = ac2.direct_imap - ac2.direct_imap.idle() + ac2.direct_imap.idle_start() chat12.send_text("hello") ac2._evtracker.wait_next_incoming_message() @@ -29,7 +29,7 @@ class TestDirectImap: chat12, chat21 = acfactory.get_chats(ac1, ac2) # send a message and check IMAP read flag - ac1.direct_imap.idle() + ac1.direct_imap.idle_start() chat21.send_text("Text message") msg_in = ac1._evtracker.wait_next_incoming_message() @@ -39,20 +39,3 @@ class TestDirectImap: msg_in.mark_seen() ac1.direct_imap.idle_check(terminate=True) assert ac1.direct_imap.get_unread_cnt() == 0 - - def test_mark_bcc_read_on_server(self, acfactory, lp): - ac1, ac2 = acfactory.get_two_online_accounts(move=True) - chat = acfactory.get_chat(ac1, ac2) - ac1.set_config("bcc_self", "1") - # wait for seen/read message to appear in mvbox - ac1.direct_imap.select_config_folder("mvbox") - ac1.direct_imap.idle() - chat.send_text("Text message") - ac1._evtracker.get_matching("DC_EVENT_SMTP_MESSAGE_SENT") - - while 1: - res = ac1.direct_imap.idle_check() - for item in res: - if item[1] == FETCH: - if item[2][0] == FLAGS and SEEN in item[2][1]: - return