mirror of
https://github.com/chatmail/core.git
synced 2026-04-06 07:32:12 +03:00
fix grouping / helper function
This commit is contained in:
@@ -11,6 +11,15 @@ from deltachat import direct_imap
|
||||
from deltachat.direct_imap import make_direct_imap
|
||||
|
||||
|
||||
def get_chat(ac1, ac2, both_created=False):
|
||||
c2 = ac1.create_contact(email=ac2.get_config("addr"))
|
||||
chat = ac1.create_chat_by_contact(c2)
|
||||
assert chat.id > const.DC_CHAT_ID_LAST_SPECIAL
|
||||
if both_created:
|
||||
ac2.create_chat_by_contact(ac2.create_contact(email=ac1.get_config("addr")))
|
||||
return chat
|
||||
|
||||
|
||||
@pytest.mark.parametrize("msgtext,res", [
|
||||
("Member Me (tmp1@x.org) removed by tmp2@x.org.", ("removed", "tmp1@x.org")),
|
||||
("Member tmp1@x.org added by tmp2@x.org.", ("added", "tmp1@x.org")),
|
||||
@@ -513,14 +522,6 @@ class TestOfflineChat:
|
||||
|
||||
|
||||
class TestOnlineAccount:
|
||||
def get_chat(self, ac1, ac2, both_created=False):
|
||||
c2 = ac1.create_contact(email=ac2.get_config("addr"))
|
||||
chat = ac1.create_chat_by_contact(c2)
|
||||
assert chat.id > const.DC_CHAT_ID_LAST_SPECIAL
|
||||
if both_created:
|
||||
ac2.create_chat_by_contact(ac2.create_contact(email=ac1.get_config("addr")))
|
||||
return chat
|
||||
|
||||
@pytest.mark.ignored
|
||||
def test_configure_generate_key(self, acfactory, lp):
|
||||
# A slow test which will generate new keys.
|
||||
@@ -538,7 +539,7 @@ class TestOnlineAccount:
|
||||
ac1.start_io()
|
||||
ac2.wait_configure_finish()
|
||||
ac2.start_io()
|
||||
chat = self.get_chat(ac1, ac2, both_created=True)
|
||||
chat = get_chat(ac1, ac2, both_created=True)
|
||||
|
||||
lp.sec("ac1: send unencrypted message to ac2")
|
||||
chat.send_text("message1")
|
||||
@@ -599,7 +600,7 @@ class TestOnlineAccount:
|
||||
ac1_clone.wait_configure_finish()
|
||||
ac1_clone.start_io()
|
||||
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
|
||||
self_addr = ac1.get_config("addr")
|
||||
other_addr = ac2.get_config("addr")
|
||||
@@ -639,7 +640,7 @@ class TestOnlineAccount:
|
||||
|
||||
def test_send_file_twice_unicode_filename_mangling(self, tmpdir, acfactory, lp):
|
||||
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
|
||||
basename = "somedäüta.html.zip"
|
||||
p = os.path.join(tmpdir.strpath, basename)
|
||||
@@ -671,7 +672,7 @@ class TestOnlineAccount:
|
||||
|
||||
def test_send_file_html_attachment(self, tmpdir, acfactory, lp):
|
||||
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
|
||||
basename = "test.html"
|
||||
content = "<html><body>text</body>data"
|
||||
@@ -709,7 +710,7 @@ class TestOnlineAccount:
|
||||
ac1.start_io()
|
||||
|
||||
lp.sec("ac1: send message and wait for ac2 to receive it")
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
chat.send_text("message1")
|
||||
ev = ac2._evtracker.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
|
||||
assert ev.data2 > const.DC_CHAT_ID_LAST_SPECIAL
|
||||
@@ -722,7 +723,7 @@ class TestOnlineAccount:
|
||||
ac2.start_io()
|
||||
ac1.wait_configure_finish()
|
||||
ac1.start_io()
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
chat.send_text("message1")
|
||||
ev = ac2._evtracker.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
|
||||
assert ev.data2 > const.DC_CHAT_ID_LAST_SPECIAL
|
||||
@@ -737,7 +738,7 @@ class TestOnlineAccount:
|
||||
ac1.wait_configure_finish()
|
||||
ac1.start_io()
|
||||
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
chat.send_text("message1")
|
||||
chat.send_text("message2")
|
||||
chat.send_text("message3")
|
||||
@@ -747,7 +748,7 @@ class TestOnlineAccount:
|
||||
|
||||
def test_forward_messages(self, acfactory, lp):
|
||||
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
|
||||
lp.sec("ac1: send message to ac2")
|
||||
msg_out = chat.send_text("message2")
|
||||
@@ -780,7 +781,7 @@ class TestOnlineAccount:
|
||||
|
||||
def test_forward_own_message(self, acfactory, lp):
|
||||
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||
chat = self.get_chat(ac1, ac2, both_created=True)
|
||||
chat = get_chat(ac1, ac2, both_created=True)
|
||||
|
||||
lp.sec("sending message")
|
||||
msg_out = chat.send_text("message2")
|
||||
@@ -822,7 +823,7 @@ class TestOnlineAccount:
|
||||
ac1.set_config("displayname", "ä name")
|
||||
|
||||
lp.sec("ac1: create chat with ac2")
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
|
||||
lp.sec("sending text message from ac1 to ac2")
|
||||
msg_out = chat.send_text("message1")
|
||||
@@ -888,7 +889,7 @@ class TestOnlineAccount:
|
||||
ac1, ac2 = acfactory.get_two_online_accounts(move=True)
|
||||
|
||||
lp.sec("ac1: create chat with ac2")
|
||||
chat = self.get_chat(ac1, ac2, both_created=True)
|
||||
chat = get_chat(ac1, ac2, both_created=True)
|
||||
|
||||
# make sure mdns are enabled (usually enabled by default already)
|
||||
ac1.set_config("mdns_enabled", "1")
|
||||
@@ -923,7 +924,7 @@ class TestOnlineAccount:
|
||||
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||
|
||||
lp.sec("ac1: create chat with ac2")
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
|
||||
lp.sec("sending text message from ac1 to ac2")
|
||||
msg_out = chat.send_text("message1")
|
||||
@@ -973,7 +974,7 @@ class TestOnlineAccount:
|
||||
ac2.set_config("save_mime_headers", "1")
|
||||
|
||||
lp.sec("ac1: create chat with ac2")
|
||||
chat = self.get_chat(ac1, ac2, both_created=True)
|
||||
chat = get_chat(ac1, ac2, both_created=True)
|
||||
|
||||
lp.sec("sending multi-line non-unicode message from ac1 to ac2")
|
||||
text1 = "hello\nworld"
|
||||
@@ -998,7 +999,7 @@ class TestOnlineAccount:
|
||||
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||
|
||||
lp.sec("ac1: create chat with ac2")
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
|
||||
lp.sec("sending text message from ac1 to ac2")
|
||||
msg_out = chat.send_text("message1")
|
||||
@@ -1052,7 +1053,7 @@ class TestOnlineAccount:
|
||||
|
||||
lp.sec("configure ac2 to save mime headers, create ac1/ac2 chat")
|
||||
ac2.set_config("save_mime_headers", "1")
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
|
||||
lp.sec("sending text message from ac1 to ac2")
|
||||
msg_out = chat.send_text("message1")
|
||||
@@ -1068,7 +1069,7 @@ class TestOnlineAccount:
|
||||
|
||||
def test_send_mark_seen_clean_incoming_events(self, acfactory, lp, data):
|
||||
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||
chat = self.get_chat(ac1, ac2, both_created=True)
|
||||
chat = get_chat(ac1, ac2, both_created=True)
|
||||
|
||||
message_queue = queue.Queue()
|
||||
|
||||
@@ -1097,7 +1098,7 @@ class TestOnlineAccount:
|
||||
|
||||
def test_send_and_receive_image(self, acfactory, lp, data):
|
||||
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
|
||||
message_queue = queue.Queue()
|
||||
|
||||
@@ -1304,7 +1305,7 @@ class TestOnlineAccount:
|
||||
ac1.set_avatar(p)
|
||||
|
||||
lp.sec("ac1: create 1:1 chat with ac2")
|
||||
chat = self.get_chat(ac1, ac2, both_created=True)
|
||||
chat = get_chat(ac1, ac2, both_created=True)
|
||||
|
||||
msg = chat.send_text("hi -- do you see my brand new avatar?")
|
||||
assert not msg.is_encrypted()
|
||||
@@ -1483,8 +1484,8 @@ class TestOnlineAccount:
|
||||
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||
|
||||
lp.sec("ac1: create chat with ac2")
|
||||
chat1 = self.get_chat(ac1, ac2)
|
||||
chat2 = self.get_chat(ac2, ac1)
|
||||
chat1 = get_chat(ac1, ac2)
|
||||
chat2 = get_chat(ac2, ac1)
|
||||
|
||||
assert not chat1.is_sending_locations()
|
||||
with pytest.raises(ValueError):
|
||||
@@ -1754,8 +1755,8 @@ class TestDirectImap:
|
||||
# imap2.mark_all_read()
|
||||
assert imap2.get_unread_cnt() == 0
|
||||
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat_on_ac2 = self.get_chat(ac2, ac1)
|
||||
chat = get_chat(ac1, ac2)
|
||||
chat_on_ac2 = get_chat(ac2, ac1)
|
||||
|
||||
chat.send_text("Text message")
|
||||
|
||||
@@ -1798,7 +1799,7 @@ class TestDirectImap:
|
||||
imap1.mark_all_read()
|
||||
assert imap1.get_unread_cnt() == 0
|
||||
|
||||
chat = self.get_chat(ac1, ac2)
|
||||
chat = get_chat(ac1, ac2)
|
||||
|
||||
ac1.set_config("bcc_self", "1")
|
||||
chat.send_text("Text message")
|
||||
|
||||
Reference in New Issue
Block a user