From 339f695bd6dc93eff64166e1748675ccc3e3c27f Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 9 Mar 2025 17:30:44 +0000 Subject: [PATCH] test(python): port test_no_old_msg_is_fresh to JSON-RPC --- deltachat-rpc-client/tests/test_something.py | 25 +++++++++++++++ python/tests/test_1_online.py | 32 -------------------- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index c552e0f59..d8a5ac7f7 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -710,3 +710,28 @@ def test_configured_imap_certificate_checks(acfactory): # Core 1.142.4, 1.142.5 and 1.142.6 saved this value due to bug. # This test is a regression test to prevent this happening again. assert configured_certificate_checks != "0" + + +def test_no_old_msg_is_fresh(acfactory): + ac1, ac2 = acfactory.get_online_accounts(2) + ac1_clone = ac1.clone() + ac1_clone.start_io() + + ac1.create_chat(ac2) + ac1_clone_chat = ac1_clone.create_chat(ac2) + + ac1.get_device_chat().mark_noticed() + + logging.info("Send a first message from ac2 to ac1 and check that it's 'fresh'") + first_msg = ac2.create_chat(ac1).send_text("Hi") + ac1.wait_for_incoming_msg_event() + assert ac1.create_chat(ac2).get_fresh_message_count() == 1 + assert len(list(ac1.get_fresh_messages())) == 1 + + logging.info("Send a message from ac1_clone to ac2 and check that ac1 marks the first message as 'noticed'") + ac1_clone_chat.send_text("Hi back") + ev = ac1.wait_for_msgs_noticed_event() + + assert ev.chat_id == first_msg.get_snapshot().chat_id + assert ac1.create_chat(ac2).get_fresh_message_count() == 0 + assert len(list(ac1.get_fresh_messages())) == 0 diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index 985417ad1..a2b09b032 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -1167,38 +1167,6 @@ def test_dont_show_emails(acfactory, lp): assert len(msg.chat.get_messages()) == 3 -def test_no_old_msg_is_fresh(acfactory, lp): - ac1 = acfactory.new_online_configuring_account() - ac2 = acfactory.new_online_configuring_account() - ac1_clone = acfactory.new_online_configuring_account(cloned_from=ac1) - acfactory.bring_accounts_online() - - ac1.set_config("e2ee_enabled", "0") - ac1_clone.set_config("e2ee_enabled", "0") - ac2.set_config("e2ee_enabled", "0") - - ac1_clone.set_config("bcc_self", "1") - - ac1.create_chat(ac2) - ac1_clone.create_chat(ac2) - - ac1.get_device_chat().mark_noticed() - - lp.sec("Send a first message from ac2 to ac1 and check that it's 'fresh'") - first_msg_id = ac2.create_chat(ac1).send_text("Hi") - ac1._evtracker.wait_next_incoming_message() - assert ac1.create_chat(ac2).count_fresh_messages() == 1 - assert len(list(ac1.get_fresh_messages())) == 1 - - lp.sec("Send a message from ac1_clone to ac2 and check that ac1 marks the first message as 'noticed'") - ac1_clone.create_chat(ac2).send_text("Hi back") - ev = ac1._evtracker.get_matching("DC_EVENT_MSGS_NOTICED") - - assert ev.data1 == first_msg_id.chat.id - assert ac1.create_chat(ac2).count_fresh_messages() == 0 - assert len(list(ac1.get_fresh_messages())) == 0 - - def test_prefer_encrypt(acfactory, lp): """Test quorum rule for encryption preference in 1:1 and group chat.""" ac1 = acfactory.new_online_configuring_account(fix_is_chatmail=True)