mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
integrate direct imap test in existing BCC test
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user