Compare commits

...

1 Commits

Author SHA1 Message Date
holger krekel
738ba9b7c4 test and fix #956 2019-12-05 01:40:57 +01:00
2 changed files with 24 additions and 2 deletions

View File

@@ -58,8 +58,6 @@ class Message(object):
def set_text(self, text):
"""set text of this message. """
assert self.id > 0, "message not prepared"
assert self.is_out_preparing()
lib.dc_msg_set_text(self._dc_msg, as_dc_charpointer(text))
@props.with_doc

View File

@@ -430,6 +430,30 @@ class TestOnlineAccount:
assert self_addr not in ev[2]
ev = ac1._evlogger.get_matching("DC_EVENT_DELETED_BLOB_FILE")
def test_prepare_file(self, acfactory, lp):
ac1, ac2 = acfactory.get_two_online_accounts()
chat = self.get_chat(ac1, ac2)
lp.sec("ac1: prepare and send attachment + text to ac2")
blobdir = ac1.get_blobdir()
p = os.path.join(blobdir, "somedata.txt")
with open(p, "w") as f:
f.write("some data")
msg = Message.new_empty(ac1, "file")
msg.set_text("hello world")
msg.set_file(p)
message = chat.prepare_message(msg)
assert message.is_out_preparing()
assert message.text == "hello world"
chat.send_prepared(message)
lp.sec("ac2: receive message")
ev = ac2._evlogger.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
assert ev[2] > const.DC_CHAT_ID_LAST_SPECIAL
msg = ac2.get_message_by_id(ev[1])
assert msg.text == "hello world"
assert open(msg.filename).read() == "some data"
def test_mvbox_sentbox_threads(self, acfactory, lp):
lp.sec("ac1: start with mvbox thread")
ac1 = acfactory.get_online_configuring_account(mvbox=True, sentbox=True)