diff --git a/python/CHANGELOG b/python/CHANGELOG index 5903a597..7c41368c 100644 --- a/python/CHANGELOG +++ b/python/CHANGELOG @@ -3,7 +3,10 @@ - add Chat.delete(), Chat.send_image() and Chat.send_file() -- renamed Chat.send_text_message to Chat.sent_text +- renamed Chat.send_text_message to Chat.send_text() + (all other send methods also have no "_msg" at the end + as it's pretty clear Chat.send_X is going to send a message + to the chat) 0.6 --- diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index 60c918d3..7ef54e60 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -197,6 +197,7 @@ class Account(object): def get_message_by_id(self, msg_id): """ return Message instance. """ + assert msg_id > 0 return Message(self._dc_context, msg_id) def mark_seen_messages(self, messages): diff --git a/python/src/deltachat/chatting.py b/python/src/deltachat/chatting.py index a1911ec1..fce5b3e1 100644 --- a/python/src/deltachat/chatting.py +++ b/python/src/deltachat/chatting.py @@ -238,6 +238,11 @@ class Message(object): """filename if there was an attachment, otherwise empty string. """ return from_dc_charpointer(lib.dc_msg_get_file(self._dc_msg)) + @property_with_doc + def basename(self): + """basename of the attachment if it exists, otherwise empty string. """ + return from_dc_charpointer(lib.dc_msg_get_filename(self._dc_msg)) + @property_with_doc def filemime(self): """mime type of the file (if it exists)""" @@ -294,7 +299,7 @@ class MessageType(object): @property_with_doc def name(self): """ human readable type name. """ - return self._mapping[self._type] + return self._mapping.get(self._type, "") def is_text(self): """ return True if it's a text message. """ diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 4bd60af9..26e00856 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -146,6 +146,7 @@ class TestOfflineAccount: assert msg.type.name == "file" assert msg.type.is_file() assert os.path.exists(msg.filename) + assert msg.filename.endswith(msg.basename) assert msg.filemime == typeout def test_chat_message_distinctions(self, acfactory):