diff --git a/python/src/deltachat/message.py b/python/src/deltachat/message.py index acb1a44a0..db5185988 100644 --- a/python/src/deltachat/message.py +++ b/python/src/deltachat/message.py @@ -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 diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 432cdea15..88cd829cb 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -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)