fix test, and cleanup according profile-image API

This commit is contained in:
holger krekel
2019-09-09 00:53:31 +02:00
parent 383d8980d6
commit 650d8c45ec
6 changed files with 78 additions and 71 deletions

View File

@@ -147,7 +147,7 @@ class TestOfflineChat:
qr = chat.get_join_qr()
assert ac2.check_qr(qr).is_ask_verifygroup
def test_get_set_profile_image(self, ac1, data):
def test_get_set_profile_image_simple(self, ac1, data):
chat = ac1.create_group_chat(name="title1")
p = data.get_path("d.png")
chat.set_profile_image(p)
@@ -614,16 +614,22 @@ class TestOnlineAccount:
ac1._evlogger.get_matching("DC_EVENT_CHAT_MODIFIED")
assert not chat.is_promoted()
lp.sec("add ac2 to unpromoted group chat")
c2 = ac1.create_contact(email=ac2.get_config("addr"))
contact1 = chat.add_contact(c2)
assert not chat.is_promoted()
# XXX first promote the chat before setting group image
# because DC does not honor it before promotion happened
# unless you add yet another member, see step below.
lp.sec("ac2: add ac1 per chat")
chat.send_text("ac1: initial message to promote chat (workaround)")
assert chat.is_promoted()
lp.sec("ac2: add ac1 to a chat so the message does not land in DEADDROP")
c1 = ac2.create_contact(email=ac1.get_config("addr"))
ac2.create_chat_by_contact(c1)
ev = ac2._evlogger.get_matching("DC_EVENT_MSGS_CHANGED")
lp.sec("ac1: add ac2 to promoted group chat")
c2 = ac1.create_contact(email=ac2.get_config("addr"))
contact1 = chat.add_contact(c2)
lp.sec("ac1: send a first message to ac2")
chat.send_text("hi")
assert chat.is_promoted()
@@ -631,11 +637,26 @@ class TestOnlineAccount:
lp.sec("ac2: wait for receiving message from ac1")
ev = ac2._evlogger.get_matching("DC_EVENT_INCOMING_MSG")
msg_in = ac2.get_message_by_id(ev[2])
assert msg_in.text == "hi"
assert not msg_in.chat.is_deaddrop()
lp.sec("ac2: create proper chat and read profile image")
lp.sec("ac2: create chat and read profile image")
chat2 = ac2.create_chat_by_message(msg_in)
p2 = chat2.get_profile_image()
assert p2 is not None
assert open(p2, "rb").read() == open(p, "rb").read()
ac2._evlogger.consume_events()
ac1._evlogger.consume_events()
lp.sec("ac2: delete profile image from chat")
chat2.remove_profile_image()
ev = ac1._evlogger.get_matching("DC_EVENT_INCOMING_MSG")
assert ev[1] == chat.id
chat1b = ac1.create_chat_by_message(ev[2])
assert chat1b.get_profile_image() is None
assert chat.get_profile_image() is None