Tweak error halding a little

- Python should raise exceptions on error.  Not return False.
- Negative durations are nonense.
- ChatID validity is already checked by the Rust API, let's not duplicate.
This commit is contained in:
Floris Bruynooghe
2020-02-09 17:59:52 +01:00
parent ded6fafc8a
commit 0242322d24
3 changed files with 7 additions and 5 deletions

View File

@@ -101,13 +101,15 @@ class Chat(object):
""" mutes the chat
:param duration: Number of seconds to mute the chat for. None to mute until unmuted again.
:returns:
:returns: None
"""
if duration is None:
mute_duration = -1
else:
mute_duration = duration
return bool(lib.dc_set_chat_mute_duration(self._dc_context, self.id, mute_duration))
ret = lib.dc_set_chat_mute_duration(self._dc_context, self.id, mute_duration)
if not bool(ret):
raise ValueError("Call to dc_set_chat_mute_duration failed")
def unmute(self):
""" unmutes the chat

View File

@@ -229,8 +229,8 @@ class TestOfflineChat:
assert not chat.is_muted()
assert chat.mute(50)
assert chat.is_muted()
assert chat.mute(-51)
assert not chat.is_muted()
with pytest.raises(ValueError):
chat.mute(-51)
def test_delete_and_send_fails(self, ac1, chat1):
chat1.delete()