1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-03 17:59:19 +02:00

add msg.basename and a few assertions

This commit is contained in:
holger krekel 2018-10-07 00:13:34 +02:00
parent 5c3e41fcb5
commit d18fc8ebf9
4 changed files with 12 additions and 2 deletions

View file

@ -3,7 +3,10 @@
- add Chat.delete(), Chat.send_image() and Chat.send_file() - 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 0.6
--- ---

View file

@ -197,6 +197,7 @@ class Account(object):
def get_message_by_id(self, msg_id): def get_message_by_id(self, msg_id):
""" return Message instance. """ """ return Message instance. """
assert msg_id > 0
return Message(self._dc_context, msg_id) return Message(self._dc_context, msg_id)
def mark_seen_messages(self, messages): def mark_seen_messages(self, messages):

View file

@ -238,6 +238,11 @@ class Message(object):
"""filename if there was an attachment, otherwise empty string. """ """filename if there was an attachment, otherwise empty string. """
return from_dc_charpointer(lib.dc_msg_get_file(self._dc_msg)) 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 @property_with_doc
def filemime(self): def filemime(self):
"""mime type of the file (if it exists)""" """mime type of the file (if it exists)"""
@ -294,7 +299,7 @@ class MessageType(object):
@property_with_doc @property_with_doc
def name(self): def name(self):
""" human readable type name. """ """ human readable type name. """
return self._mapping[self._type] return self._mapping.get(self._type, "")
def is_text(self): def is_text(self):
""" return True if it's a text message. """ """ return True if it's a text message. """

View file

@ -146,6 +146,7 @@ class TestOfflineAccount:
assert msg.type.name == "file" assert msg.type.name == "file"
assert msg.type.is_file() assert msg.type.is_file()
assert os.path.exists(msg.filename) assert os.path.exists(msg.filename)
assert msg.filename.endswith(msg.basename)
assert msg.filemime == typeout assert msg.filemime == typeout
def test_chat_message_distinctions(self, acfactory): def test_chat_message_distinctions(self, acfactory):