python bindings for archive and py tests

This commit is contained in:
Simon Laux
2020-02-10 20:03:43 +01:00
committed by B. Petersen
parent 23b6178e78
commit ac4b2b9dfe
2 changed files with 32 additions and 1 deletions

View File

@@ -424,13 +424,33 @@ class Chat(object):
:returns: True if archived.
"""
return lib.dc_chat_get_archived(self._dc_chat) == 1
def is_pinned(self):
"""return True if this chat is pinned.
:returns: True if pinned.
"""
return lib.dc_chat_get_archived(self._dc_chat) == 2
def archive(self):
"""archive the chat.
"""
lib.dc_archive_chat(self._dc_context, self.id, 1)
def unarchive(self):
"""unarchive the chat.
"""
lib.dc_archive_chat(self._dc_context, self.id, 0)
def pin(self):
"""pin the chat.
"""
lib.dc_archive_chat(self._dc_context, self.id, 2)
def unpin(self):
"""unpin the chat. (same as unarchive)
"""
self.unarchive()
def enable_sending_locations(self, seconds):
"""enable sending locations for this chat.

View File

@@ -426,6 +426,17 @@ class TestOfflineChat:
chat.remove_contact(contacts[3])
assert len(chat.get_contacts()) == 9
def test_archive_and_pin_chat(self, ac1):
chat = ac1.create_group_chat(name="title1")
assert not chat.is_archived()
chat.archive()
assert chat.is_archived()
chat.unarchive()
assert not chat.is_archived()
chat.pin()
assert chat.is_pinned()
class TestOnlineAccount:
@pytest.mark.ignored