Skip to content

Commit

Permalink
Make room_id required on im.counters
Browse files Browse the repository at this point in the history
since the arguments changed their required/optional requirements
  • Loading branch information
jadolg committed Aug 8, 2022
1 parent 599a379 commit 67e91b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
18 changes: 8 additions & 10 deletions rocketchat_API/APISections/im.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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)
4 changes: 1 addition & 3 deletions tests/test_ims.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 67e91b6

Please sign in to comment.