Skip to content

Commit

Permalink
Merge pull request #165 from herronelou/master
Browse files Browse the repository at this point in the history
Backport to Python 2.7
  • Loading branch information
jadolg authored Aug 9, 2022
2 parents 65ce2b0 + 2f33caf commit 0cd5dab
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 27 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10' ]
python-version: [ '2.7', '3.8', '3.9', '3.10' ]
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
Expand All @@ -27,9 +27,13 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install pytest-cov black requests
run: pip install pytest-cov requests
- name: Install black
run: pip install black
if: matrix.python-version != '2.7' # Black does not run on python 2.7
- name: Lint with black
run: black --check .
if: matrix.python-version != '2.7' # Black does not run on python 2.7
- name: Wait for rocket.chat server to be online
run: until curl --silent http://localhost:3000/api/info/; do sleep 15; echo "waiting for Rocket.Chat server to start"; done;
- name: Run tests
Expand Down
8 changes: 4 additions & 4 deletions rocketchat_API/APISections/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def channels_list_joined(self, **kwargs):
return self.call_api_get("channels.list.joined", kwargs=kwargs)

def channels_info(self, room_id=None, channel=None, **kwargs):
"""Gets a channels information."""
"""Gets a channel's information."""
if room_id:
return self.call_api_get("channels.info", roomId=room_id, kwargs=kwargs)
if channel:
Expand Down Expand Up @@ -92,11 +92,11 @@ def channels_unarchive(self, room_id, **kwargs):
return self.call_api_post("channels.unarchive", roomId=room_id, kwargs=kwargs)

def channels_close(self, room_id, **kwargs):
"""Removes the channel from the users list of channels."""
"""Removes the channel from the user's list of channels."""
return self.call_api_post("channels.close", roomId=room_id, kwargs=kwargs)

def channels_open(self, room_id, **kwargs):
"""Adds the channel back to the users list of channels."""
"""Adds the channel back to the user's list of channels."""
return self.call_api_post("channels.open", roomId=room_id, kwargs=kwargs)

def channels_create(self, name, **kwargs):
Expand Down Expand Up @@ -218,7 +218,7 @@ def channels_members(self, room_id=None, channel=None, **kwargs):
raise RocketMissingParamException("room_id or channel required")

def channels_roles(self, room_id=None, room_name=None, **kwargs):
"""Lists all users roles in the channel."""
"""Lists all user's roles in the channel."""
if room_id:
return self.call_api_get("channels.roles", roomId=room_id, kwargs=kwargs)
if room_name:
Expand Down
14 changes: 7 additions & 7 deletions rocketchat_API/APISections/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ def groups_remove_owner(self, room_id, user_id, **kwargs):
)

def groups_archive(self, room_id, **kwargs):
"""Archives a private group, only if youre part of the group."""
"""Archives a private group, only if you're part of the group."""
return self.call_api_post("groups.archive", roomId=room_id, kwargs=kwargs)

def groups_unarchive(self, room_id, **kwargs):
"""Unarchives a private group."""
return self.call_api_post("groups.unarchive", roomId=room_id, kwargs=kwargs)

def groups_close(self, room_id, **kwargs):
"""Removes the private group from the users list of groups, only if youre part of the group."""
"""Removes the private group from the user's list of groups, only if you're part of the group."""
return self.call_api_post("groups.close", roomId=room_id, kwargs=kwargs)

def groups_create(self, name, **kwargs):
"""Creates a new private group, optionally including users, only if youre part of the group."""
"""Creates a new private group, optionally including users, only if you're part of the group."""
return self.call_api_post("groups.create", name=name, kwargs=kwargs)

def groups_get_integrations(self, room_id, **kwargs):
Expand All @@ -73,7 +73,7 @@ def groups_get_integrations(self, room_id, **kwargs):
)

def groups_info(self, room_id=None, room_name=None, **kwargs):
"""GRetrieves the information about the private group, only if youre part of the group."""
"""GRetrieves the information about the private group, only if you're part of the group."""
if room_id:
return self.call_api_get("groups.info", roomId=room_id, kwargs=kwargs)
if room_name:
Expand All @@ -93,11 +93,11 @@ def groups_kick(self, room_id, user_id, **kwargs):
)

def groups_leave(self, room_id, **kwargs):
"""Causes the callee to be removed from the private group, if theyre part of it and are not the last owner."""
"""Causes the callee to be removed from the private group, if they're part of it and are not the last owner."""
return self.call_api_post("groups.leave", roomId=room_id, kwargs=kwargs)

def groups_open(self, room_id, **kwargs):
"""Adds the private group back to the users list of private groups."""
"""Adds the private group back to the user's list of private groups."""
return self.call_api_post("groups.open", roomId=room_id, kwargs=kwargs)

def groups_rename(self, room_id, name, **kwargs):
Expand Down Expand Up @@ -181,7 +181,7 @@ def groups_members(self, room_id=None, group=None, **kwargs):
raise RocketMissingParamException("room_id or group required")

def groups_roles(self, room_id=None, room_name=None, **kwargs):
"""Lists all users roles in the private group."""
"""Lists all user's roles in the private group."""
if room_id:
return self.call_api_get("groups.roles", roomId=room_id, kwargs=kwargs)
if room_name:
Expand Down
4 changes: 2 additions & 2 deletions rocketchat_API/APISections/im.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def im_create_multiple(self, usernames, **kwargs):
)

def im_open(self, room_id, **kwargs):
"""Adds the direct message back to the users list of direct messages."""
"""Adds the direct message back to the user's list of direct messages."""
return self.call_api_post("im.open", roomId=room_id, kwargs=kwargs)

def im_close(self, room_id, **kwargs):
"""Removes the direct message from the users list of direct messages."""
"""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):
Expand Down
14 changes: 8 additions & 6 deletions rocketchat_API/APISections/livechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ def livechat_inquiries_take(self, inquiry_id, **kwargs):

def livechat_get_users(self, user_type, **kwargs):
"""Get a list of agents or managers."""
return self.call_api_get(f"livechat/users/{user_type}", kwargs=kwargs)
return self.call_api_get("livechat/users/{}".format(user_type), kwargs=kwargs)

def livechat_create_user(self, user_type, **kwargs):
"""Register a new agent or manager."""
return self.call_api_post(f"livechat/users/{user_type}", kwargs=kwargs)
return self.call_api_post("livechat/users/{}".format(user_type), kwargs=kwargs)

def livechat_get_user(self, user_type, user_id, **kwargs):
"""Get info about an agent or manager."""
return self.call_api_get(f"livechat/users/{user_type}/{user_id}", kwargs=kwargs)
return self.call_api_get(
"livechat/users/{}/{}".format(user_type, user_id), kwargs=kwargs
)

def livechat_delete_user(self, user_type, user_id):
"""Removes an agent or manager."""
return self.call_api_delete(f"livechat/users/{user_type}/{user_id}")
return self.call_api_delete("livechat/users/{}/{}".format(user_type, user_id))

def livechat_register_visitor(self, token, **kwargs):
"""Register a new Livechat visitor."""
Expand All @@ -41,7 +43,7 @@ def livechat_register_visitor(self, token, **kwargs):

def livechat_get_visitor(self, token):
"""Retrieve a visitor data."""
return self.call_api_get(f"livechat/visitor/{token}")
return self.call_api_get("livechat/visitor/{}".format(token))

def livechat_room(self, token, **kwargs):
"""Get the Livechat room data or open a new room."""
Expand All @@ -56,5 +58,5 @@ def livechat_message(self, token, rid, msg, **kwargs):
def livechat_messages_history(self, rid, token, **kwargs):
"""Load Livechat messages history."""
return self.call_api_get(
f"livechat/messages.history/{rid}", token=token, kwargs=kwargs
"livechat/messages.history/{}".format(rid), token=token, kwargs=kwargs
)
10 changes: 5 additions & 5 deletions rocketchat_API/APISections/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def me(self, **kwargs):
return self.call_api_get("me", kwargs=kwargs)

def users_info(self, user_id=None, username=None, **kwargs):
"""Gets a users information, limited to the callers permissions."""
"""Gets a user's information, limited to the caller's permissions."""
if user_id:
return self.call_api_get("users.info", userId=user_id, kwargs=kwargs)
if username:
Expand Down Expand Up @@ -59,7 +59,7 @@ def users_register(self, email, name, password, username, **kwargs):
)

def users_get_avatar(self, user_id=None, username=None, **kwargs):
"""Gets the URL for a users avatar."""
"""Gets the URL for a user's avatar."""
if user_id:
response = self.call_api_get(
"users.getAvatar", userId=user_id, kwargs=kwargs
Expand All @@ -84,7 +84,7 @@ def users_get_avatar(self, user_id=None, username=None, **kwargs):
return response

def users_set_avatar(self, avatar_url, **kwargs):
"""Set a users avatar"""
"""Set a user's avatar"""
if avatar_url.startswith("http://") or avatar_url.startswith("https://"):
return self.call_api_post(
"users.setAvatar", avatarUrl=avatar_url, kwargs=kwargs
Expand All @@ -101,7 +101,7 @@ def users_set_avatar(self, avatar_url, **kwargs):
return self.call_api_post("users.setAvatar", files=avatar_file, kwargs=kwargs)

def users_reset_avatar(self, user_id=None, username=None, **kwargs):
"""Reset a users avatar"""
"""Reset a user's avatar"""
if user_id:
return self.call_api_post(
"users.resetAvatar", userId=user_id, kwargs=kwargs
Expand Down Expand Up @@ -146,7 +146,7 @@ def users_get_preferences(self, **kwargs):
return self.call_api_get("users.getPreferences", kwargs=kwargs)

def users_set_preferences(self, user_id, data, **kwargs):
"""Set users preferences."""
"""Set user's preferences."""
return self.call_api_post(
"users.setPreferences", userId=user_id, data=data, kwargs=kwargs
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_users_create_token(logged_rocket, user):
def test_users_create_update_delete(logged_rocket, user):
name = str(uuid.uuid1())
users_create = logged_rocket.users_create(
email=f"{name}@domain.com",
email="{}@domain.com".format(name),
name=name,
password=user.password,
username=name,
Expand Down

0 comments on commit 0cd5dab

Please sign in to comment.