From 67e91b661cf2230321b17867dc322c10e0a0a034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Alberto=20D=C3=ADaz=20Orozco=20=28Akiel=29?= Date: Mon, 8 Aug 2022 20:19:39 +0200 Subject: [PATCH] Make room_id required on im.counters since the arguments changed their required/optional requirements --- rocketchat_API/APISections/im.py | 18 ++++++++---------- tests/test_ims.py | 4 +--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/rocketchat_API/APISections/im.py b/rocketchat_API/APISections/im.py index af8d803..cb41b95 100644 --- a/rocketchat_API/APISections/im.py +++ b/rocketchat_API/APISections/im.py @@ -33,17 +33,17 @@ def im_close(self, room_id, **kwargs): """Removes the direct message from the user’s list of direct messages.""" return self.call_api_post("im.close", roomId=room_id, kwargs=kwargs) - def im_members(self, room_id, **kwargs): + def im_members(self, room_id): """Retrieves members of a direct message.""" - return self.call_api_get("im.members", roomId=room_id, args=kwargs) + return self.call_api_get("im.members", roomId=room_id) - def im_messages(self, room_id=None, username=None, **kwargs): + def im_messages(self, room_id=None, username=None): """Retrieves direct messages from the server by username""" if room_id: - return self.call_api_get("im.messages", roomId=room_id, args=kwargs) + return self.call_api_get("im.messages", roomId=room_id) if username: - return self.call_api_get("im.messages", username=username, args=kwargs) + return self.call_api_get("im.messages", username=username) raise RocketMissingParamException("roomId or username required") @@ -65,10 +65,8 @@ def im_files(self, room_id=None, user_name=None, **kwargs): return self.call_api_get("im.files", username=user_name, kwargs=kwargs) raise RocketMissingParamException("roomId or username required") - def im_counters(self, room_id=None, user_name=None, **kwargs): + def im_counters(self, room_id, user_name=None): """Gets counters of direct messages.""" - if room_id: - return self.call_api_get("im.counters", roomId=room_id, kwargs=kwargs) if user_name: - return self.call_api_get("im.counters", username=user_name, kwargs=kwargs) - raise RocketMissingParamException("roomId or username required") + return self.call_api_get("im.counters", roomId=room_id, username=user_name) + return self.call_api_get("im.counters", roomId=room_id) diff --git a/tests/test_ims.py b/tests/test_ims.py index dd3616b..b2e2d95 100644 --- a/tests/test_ims.py +++ b/tests/test_ims.py @@ -143,9 +143,7 @@ def test_im_counters(logged_rocket, recipient_user): assert im_counters.get("success") im_counters = logged_rocket.im_counters( + room_id=im_create.get("room").get("_id"), user_name=logged_rocket.me().json().get("_id") ).json() assert im_counters.get("success") - - with pytest.raises(RocketMissingParamException): - logged_rocket.im_counters()