Skip to content

Commit 84a9e6c

Browse files
committed
test: port folder-related CFFI tests to JSON-RPC
Created new test_folders.py Moved existing JSON-RPC tests: - test_reactions_for_a_reordering_move - test_delete_deltachat_folder Ported tests: - test_move_works_on_self_sent - test_moved_markseen - test_markseen_message_and_mdn - test_mvbox_thread_and_trash (renamed to test_mvbox_and_trash) - test_scan_folders - test_move_works - test_move_avoids_loop - test_immediate_autodelete - test_trash_multiple_messages The change also contains fixes for direct_imap fixture needed to use IMAP IDLE in JSON-RPC tests.
1 parent d39ed9d commit 84a9e6c

File tree

4 files changed

+580
-531
lines changed

4 files changed

+580
-531
lines changed

deltachat-rpc-client/tests/conftest.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ def delete(self, uid_list: str, expunge=True):
8585

8686
def get_all_messages(self) -> list[MailMessage]:
8787
assert not self._idling
88-
return list(self.conn.fetch())
88+
return list(self.conn.fetch(mark_seen=False))
8989

9090
def get_unread_messages(self) -> list[str]:
9191
assert not self._idling
92-
return [msg.uid for msg in self.conn.fetch(AND(seen=False))]
92+
return [msg.uid for msg in self.conn.fetch(AND(seen=False), mark_seen=False)]
9393

9494
def mark_all_read(self):
9595
messages = self.get_unread_messages()
@@ -173,33 +173,27 @@ def get_uid_by_message_id(self, message_id) -> str:
173173
class IdleManager:
174174
def __init__(self, direct_imap) -> None:
175175
self.direct_imap = direct_imap
176-
self.log = direct_imap.account.log
177176
# fetch latest messages before starting idle so that it only
178177
# returns messages that arrive anew
179178
self.direct_imap.conn.fetch("1:*")
180179
self.direct_imap.conn.idle.start()
181180

182181
def check(self, timeout=None) -> list[bytes]:
183182
"""(blocking) wait for next idle message from server."""
184-
self.log("imap-direct: calling idle_check")
185-
res = self.direct_imap.conn.idle.poll(timeout=timeout)
186-
self.log(f"imap-direct: idle_check returned {res!r}")
187-
return res
183+
return self.direct_imap.conn.idle.poll(timeout=timeout)
188184

189-
def wait_for_new_message(self, timeout=None) -> bytes:
185+
def wait_for_new_message(self) -> bytes:
190186
while True:
191-
for item in self.check(timeout=timeout):
187+
for item in self.check():
192188
if b"EXISTS" in item or b"RECENT" in item:
193189
return item
194190

195191
def wait_for_seen(self, timeout=None) -> int:
196192
"""Return first message with SEEN flag from a running idle-stream."""
197193
while True:
198194
for item in self.check(timeout=timeout):
199-
if FETCH in item:
200-
self.log(str(item))
201-
if FLAGS in item and rb"\Seen" in item:
202-
return int(item.split(b" ")[1])
195+
if FETCH in item and FLAGS in item and rb"\Seen" in item:
196+
return int(item.split(b" ")[1])
203197

204198
def done(self):
205199
"""send idle-done to server if we are currently in idle mode."""

0 commit comments

Comments
 (0)