mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 12:56:30 +03:00
test: port test_synchronize_member_list_on_group_rejoin to JSON-RPC
This commit is contained in:
@@ -1012,3 +1012,47 @@ def test_message_exists(acfactory):
|
|||||||
ac1.remove()
|
ac1.remove()
|
||||||
assert not message1.exists()
|
assert not message1.exists()
|
||||||
assert not message2.exists()
|
assert not message2.exists()
|
||||||
|
|
||||||
|
|
||||||
|
def test_synchronize_member_list_on_group_rejoin(acfactory, log):
|
||||||
|
"""
|
||||||
|
Test that user recreates group member list when it joins the group again.
|
||||||
|
ac1 creates a group with two other accounts: ac2 and ac3
|
||||||
|
Then it removes ac2, removes ac3 and adds ac2 back.
|
||||||
|
ac2 did not see that ac3 is removed, so it should rebuild member list from scratch.
|
||||||
|
"""
|
||||||
|
log.section("setting up accounts, accepted with each other")
|
||||||
|
ac1, ac2, ac3 = accounts = acfactory.get_online_accounts(3)
|
||||||
|
|
||||||
|
log.section("ac1: creating group chat with 2 other members")
|
||||||
|
chat = ac1.create_group("title1")
|
||||||
|
chat.add_contact(ac2)
|
||||||
|
chat.add_contact(ac3)
|
||||||
|
|
||||||
|
log.section("ac1: send message to new group chat")
|
||||||
|
msg = chat.send_text("hello")
|
||||||
|
assert chat.num_contacts() == 3
|
||||||
|
|
||||||
|
log.section("checking that the chat arrived correctly")
|
||||||
|
for ac in accounts[1:]:
|
||||||
|
msg = ac.wait_for_incoming_msg().get_snapshot()
|
||||||
|
assert msg.text == "hello"
|
||||||
|
assert msg.chat.num_contacts() == 3
|
||||||
|
msg.chat.accept()
|
||||||
|
|
||||||
|
log.section("ac1: removing ac2")
|
||||||
|
chat.remove_contact(ac2)
|
||||||
|
|
||||||
|
log.section("ac2: wait for a message about removal from the chat")
|
||||||
|
ac2.wait_for_incoming_msg()
|
||||||
|
log.section("ac1: removing ac3")
|
||||||
|
chat.remove_contact(ac3)
|
||||||
|
|
||||||
|
log.section("ac1: adding ac2 back")
|
||||||
|
chat.add_contact(ac2)
|
||||||
|
|
||||||
|
log.section("ac2: check that ac3 is removed")
|
||||||
|
msg = ac2.wait_for_incoming_msg()
|
||||||
|
|
||||||
|
assert chat.num_contacts() == 2
|
||||||
|
assert msg.get_snapshot().chat.num_contacts() == 2
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import deltachat as dc
|
import deltachat as dc
|
||||||
@@ -63,56 +62,6 @@ class TestGroupStressTests:
|
|||||||
# Message should be encrypted because keys of other members are gossiped
|
# Message should be encrypted because keys of other members are gossiped
|
||||||
assert msg.is_encrypted()
|
assert msg.is_encrypted()
|
||||||
|
|
||||||
def test_synchronize_member_list_on_group_rejoin(self, acfactory, lp):
|
|
||||||
"""
|
|
||||||
Test that user recreates group member list when it joins the group again.
|
|
||||||
ac1 creates a group with two other accounts: ac2 and ac3
|
|
||||||
Then it removes ac2, removes ac3 and adds ac2 back.
|
|
||||||
ac2 did not see that ac3 is removed, so it should rebuild member list from scratch.
|
|
||||||
"""
|
|
||||||
lp.sec("setting up accounts, accepted with each other")
|
|
||||||
accounts = acfactory.get_online_accounts(3)
|
|
||||||
acfactory.introduce_each_other(accounts)
|
|
||||||
ac1, ac2, ac3 = accounts
|
|
||||||
|
|
||||||
lp.sec("ac1: creating group chat with 2 other members")
|
|
||||||
chat = ac1.create_group_chat("title1", contacts=[ac2, ac3])
|
|
||||||
assert not chat.is_promoted()
|
|
||||||
|
|
||||||
lp.sec("ac1: send message to new group chat")
|
|
||||||
msg = chat.send_text("hello")
|
|
||||||
assert chat.is_promoted() and msg.is_encrypted()
|
|
||||||
|
|
||||||
assert chat.num_contacts() == 3
|
|
||||||
|
|
||||||
lp.sec("checking that the chat arrived correctly")
|
|
||||||
for ac in accounts[1:]:
|
|
||||||
msg = ac._evtracker.wait_next_incoming_message()
|
|
||||||
assert msg.text == "hello"
|
|
||||||
print("chat is", msg.chat)
|
|
||||||
assert msg.chat.num_contacts() == 3
|
|
||||||
|
|
||||||
lp.sec("ac1: removing ac2")
|
|
||||||
chat.remove_contact(ac2)
|
|
||||||
|
|
||||||
lp.sec("ac2: wait for a message about removal from the chat")
|
|
||||||
msg = ac2._evtracker.wait_next_incoming_message()
|
|
||||||
|
|
||||||
lp.sec("ac1: removing ac3")
|
|
||||||
chat.remove_contact(ac3)
|
|
||||||
|
|
||||||
lp.sec("ac1: adding ac2 back")
|
|
||||||
# Group is promoted, message is sent automatically
|
|
||||||
assert chat.is_promoted()
|
|
||||||
chat.add_contact(ac2)
|
|
||||||
|
|
||||||
lp.sec("ac2: check that ac3 is removed")
|
|
||||||
msg = ac2._evtracker.wait_next_incoming_message()
|
|
||||||
|
|
||||||
assert chat.num_contacts() == 2
|
|
||||||
assert msg.chat.num_contacts() == 2
|
|
||||||
acfactory.dump_imap_summary(sys.stdout)
|
|
||||||
|
|
||||||
|
|
||||||
def test_qr_verified_group_and_chatting(acfactory, lp):
|
def test_qr_verified_group_and_chatting(acfactory, lp):
|
||||||
ac1, ac2, ac3 = acfactory.get_online_accounts(3)
|
ac1, ac2, ac3 = acfactory.get_online_accounts(3)
|
||||||
|
|||||||
Reference in New Issue
Block a user