Skip to content

Commit 1ee9a82

Browse files
committed
test: port test_synchronize_member_list_on_group_rejoin to JSON-RPC
1 parent 9fa231a commit 1ee9a82

File tree

2 files changed

+44
-51
lines changed

2 files changed

+44
-51
lines changed

deltachat-rpc-client/tests/test_something.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,3 +1012,47 @@ def test_message_exists(acfactory):
10121012
ac1.remove()
10131013
assert not message1.exists()
10141014
assert not message2.exists()
1015+
1016+
1017+
def test_synchronize_member_list_on_group_rejoin(acfactory, log):
1018+
"""
1019+
Test that user recreates group member list when it joins the group again.
1020+
ac1 creates a group with two other accounts: ac2 and ac3
1021+
Then it removes ac2, removes ac3 and adds ac2 back.
1022+
ac2 did not see that ac3 is removed, so it should rebuild member list from scratch.
1023+
"""
1024+
log.section("setting up accounts, accepted with each other")
1025+
ac1, ac2, ac3 = accounts = acfactory.get_online_accounts(3)
1026+
1027+
log.section("ac1: creating group chat with 2 other members")
1028+
chat = ac1.create_group("title1")
1029+
chat.add_contact(ac2)
1030+
chat.add_contact(ac3)
1031+
1032+
log.section("ac1: send message to new group chat")
1033+
msg = chat.send_text("hello")
1034+
assert chat.num_contacts() == 3
1035+
1036+
log.section("checking that the chat arrived correctly")
1037+
for ac in accounts[1:]:
1038+
msg = ac.wait_for_incoming_msg().get_snapshot()
1039+
assert msg.text == "hello"
1040+
assert msg.chat.num_contacts() == 3
1041+
msg.chat.accept()
1042+
1043+
log.section("ac1: removing ac2")
1044+
chat.remove_contact(ac2)
1045+
1046+
log.section("ac2: wait for a message about removal from the chat")
1047+
ac2.wait_for_incoming_msg()
1048+
log.section("ac1: removing ac3")
1049+
chat.remove_contact(ac3)
1050+
1051+
log.section("ac1: adding ac2 back")
1052+
chat.add_contact(ac2)
1053+
1054+
log.section("ac2: check that ac3 is removed")
1055+
msg = ac2.wait_for_incoming_msg()
1056+
1057+
assert chat.num_contacts() == 2
1058+
assert msg.get_snapshot().chat.num_contacts() == 2

python/tests/test_0_complex_or_slow.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import time
32

43
import deltachat as dc
@@ -63,56 +62,6 @@ def test_group_many_members_add_leave_remove(self, acfactory, lp):
6362
# Message should be encrypted because keys of other members are gossiped
6463
assert msg.is_encrypted()
6564

66-
def test_synchronize_member_list_on_group_rejoin(self, acfactory, lp):
67-
"""
68-
Test that user recreates group member list when it joins the group again.
69-
ac1 creates a group with two other accounts: ac2 and ac3
70-
Then it removes ac2, removes ac3 and adds ac2 back.
71-
ac2 did not see that ac3 is removed, so it should rebuild member list from scratch.
72-
"""
73-
lp.sec("setting up accounts, accepted with each other")
74-
accounts = acfactory.get_online_accounts(3)
75-
acfactory.introduce_each_other(accounts)
76-
ac1, ac2, ac3 = accounts
77-
78-
lp.sec("ac1: creating group chat with 2 other members")
79-
chat = ac1.create_group_chat("title1", contacts=[ac2, ac3])
80-
assert not chat.is_promoted()
81-
82-
lp.sec("ac1: send message to new group chat")
83-
msg = chat.send_text("hello")
84-
assert chat.is_promoted() and msg.is_encrypted()
85-
86-
assert chat.num_contacts() == 3
87-
88-
lp.sec("checking that the chat arrived correctly")
89-
for ac in accounts[1:]:
90-
msg = ac._evtracker.wait_next_incoming_message()
91-
assert msg.text == "hello"
92-
print("chat is", msg.chat)
93-
assert msg.chat.num_contacts() == 3
94-
95-
lp.sec("ac1: removing ac2")
96-
chat.remove_contact(ac2)
97-
98-
lp.sec("ac2: wait for a message about removal from the chat")
99-
msg = ac2._evtracker.wait_next_incoming_message()
100-
101-
lp.sec("ac1: removing ac3")
102-
chat.remove_contact(ac3)
103-
104-
lp.sec("ac1: adding ac2 back")
105-
# Group is promoted, message is sent automatically
106-
assert chat.is_promoted()
107-
chat.add_contact(ac2)
108-
109-
lp.sec("ac2: check that ac3 is removed")
110-
msg = ac2._evtracker.wait_next_incoming_message()
111-
112-
assert chat.num_contacts() == 2
113-
assert msg.chat.num_contacts() == 2
114-
acfactory.dump_imap_summary(sys.stdout)
115-
11665

11766
def test_qr_verified_group_and_chatting(acfactory, lp):
11867
ac1, ac2, ac3 = acfactory.get_online_accounts(3)

0 commit comments

Comments
 (0)