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:
parent
5c3e41fcb5
commit
d18fc8ebf9
4 changed files with 12 additions and 2 deletions
|
@ -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
|
||||
---
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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. """
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue