Skip to content

Commit 13ecfae

Browse files
committed
test: port test_trash_multiple_messages from CFFI to JSON-RPC
1 parent be4f487 commit 13ecfae

File tree

2 files changed

+52
-49
lines changed

2 files changed

+52
-49
lines changed

deltachat-rpc-client/tests/test_folders.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,55 @@ def test_scan_folders(acfactory, log, direct_imap, folder, move, expected_destin
484484
if folder != expected_destination:
485485
ac1_direct_imap.select_folder(folder)
486486
assert len(ac1_direct_imap.get_all_messages()) == 0
487+
488+
489+
def test_trash_multiple_messages(acfactory, direct_imap, log):
490+
ac1, ac2 = acfactory.get_online_accounts(2)
491+
ac2.stop_io()
492+
493+
# Create the Trash folder on IMAP server and configure deletion to it. There was a bug that if
494+
# Trash wasn't configured initially, it can't be configured later, let's check this.
495+
log.section("Creating trash folder")
496+
ac2_direct_imap = direct_imap(ac2)
497+
ac2_direct_imap.create_folder("Trash")
498+
ac2.set_config("delete_server_after", "0")
499+
ac2.set_config("sync_msgs", "0")
500+
ac2.set_config("delete_to_trash", "1")
501+
502+
log.section("Check that Trash can be configured initially as well")
503+
ac3 = ac2.clone()
504+
ac3.bring_online()
505+
assert ac3.get_config("configured_trash_folder")
506+
ac3.stop_io()
507+
508+
ac2.start_io()
509+
chat12 = acfactory.get_accepted_chat(ac1, ac2)
510+
511+
log.section("ac1: sending 3 messages")
512+
texts = ["first", "second", "third"]
513+
for text in texts:
514+
chat12.send_text(text)
515+
516+
log.section("ac2: waiting for all messages on the other side")
517+
to_delete = []
518+
for text in texts:
519+
msg = ac2.wait_for_incoming_msg().get_snapshot()
520+
assert msg.text in texts
521+
if text != "second":
522+
to_delete.append(msg)
523+
# ac2 has received some messages, this is impossible w/o the trash folder configured, let's
524+
# check the configuration.
525+
assert ac2.get_config("configured_trash_folder") == "Trash"
526+
527+
log.section("ac2: deleting all messages except second")
528+
assert len(to_delete) == len(texts) - 1
529+
ac2.delete_messages(to_delete)
530+
531+
log.section("ac2: test that only one message is left")
532+
while 1:
533+
ac2.wait_for_event(EventType.IMAP_MESSAGE_MOVED)
534+
ac2_direct_imap.select_config_folder("inbox")
535+
nr_msgs = len(ac2_direct_imap.get_all_messages())
536+
assert nr_msgs > 0
537+
if nr_msgs == 1:
538+
break

python/tests/test_1_online.py

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,55 +1251,6 @@ def test_delete_multiple_messages(acfactory, lp):
12511251
break
12521252

12531253

1254-
def test_trash_multiple_messages(acfactory, lp):
1255-
ac1, ac2 = acfactory.get_online_accounts(2)
1256-
ac2.stop_io()
1257-
1258-
# Create the Trash folder on IMAP server and configure deletion to it. There was a bug that if
1259-
# Trash wasn't configured initially, it can't be configured later, let's check this.
1260-
lp.sec("Creating trash folder")
1261-
ac2.direct_imap.create_folder("Trash")
1262-
ac2.set_config("delete_to_trash", "1")
1263-
1264-
lp.sec("Check that Trash can be configured initially as well")
1265-
ac3 = acfactory.new_online_configuring_account(cloned_from=ac2)
1266-
acfactory.bring_accounts_online()
1267-
assert ac3.get_config("configured_trash_folder")
1268-
ac3.stop_io()
1269-
1270-
ac2.start_io()
1271-
chat12 = acfactory.get_accepted_chat(ac1, ac2)
1272-
1273-
lp.sec("ac1: sending 3 messages")
1274-
texts = ["first", "second", "third"]
1275-
for text in texts:
1276-
chat12.send_text(text)
1277-
1278-
lp.sec("ac2: waiting for all messages on the other side")
1279-
to_delete = []
1280-
for text in texts:
1281-
msg = ac2._evtracker.wait_next_incoming_message()
1282-
assert msg.text in texts
1283-
if text != "second":
1284-
to_delete.append(msg)
1285-
# ac2 has received some messages, this is impossible w/o the trash folder configured, let's
1286-
# check the configuration.
1287-
assert ac2.get_config("configured_trash_folder") == "Trash"
1288-
1289-
lp.sec("ac2: deleting all messages except second")
1290-
assert len(to_delete) == len(texts) - 1
1291-
ac2.delete_messages(to_delete)
1292-
1293-
lp.sec("ac2: test that only one message is left")
1294-
while 1:
1295-
ac2._evtracker.get_matching("DC_EVENT_IMAP_MESSAGE_MOVED")
1296-
ac2.direct_imap.select_config_folder("inbox")
1297-
nr_msgs = len(ac2.direct_imap.get_all_messages())
1298-
assert nr_msgs > 0
1299-
if nr_msgs == 1:
1300-
break
1301-
1302-
13031254
def test_configure_error_msgs_wrong_pw(acfactory):
13041255
(ac1,) = acfactory.get_online_accounts(1)
13051256

0 commit comments

Comments
 (0)