Skip to content

Commit

Permalink
Merge pull request #161 from sistason/channel_default
Browse files Browse the repository at this point in the history
Add channels.SetDefault and tests
  • Loading branch information
jadolg authored May 7, 2022
2 parents 4ed45bf + c99c308 commit 8003485
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
9 changes: 9 additions & 0 deletions rocketchat_API/APISections/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ def channels_rename(self, room_id, name, **kwargs):
"channels.rename", roomId=room_id, name=name, kwargs=kwargs
)

def channels_set_default(self, room_id, default, **kwargs):
"""Sets whether the channel is a default channel or not."""
return self.call_api_post(
"channels.setDefault",
roomId=room_id,
default=default,
kwargs=kwargs,
)

def channels_set_description(self, room_id, description, **kwargs):
"""Sets the description for the channel."""
return self.call_api_post(
Expand Down
11 changes: 11 additions & 0 deletions tests/test_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,14 @@ def test_channels_online(logged_rocket):
channels_online = logged_rocket.channels_online(query={"_id": "GENERAL"}).json()
assert channels_online.get("success")
assert len(channels_online.get("online")) >= 1


def test_channels_set_default(logged_rocket):
channels_set_default = logged_rocket.channels_set_default(
room_id="GENERAL", default=False
).json()
assert channels_set_default.get("channel").get("default") is False
channels_set_default = logged_rocket.channels_set_default(
room_id="GENERAL", default=True
).json()
assert channels_set_default.get("channel").get("default")
17 changes: 16 additions & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,24 @@ def test_settings_public(rocket):


def test_settings_oauth(logged_rocket):
# refresh is not done with any API call ever, so we need to call it manually here
response = logged_rocket.call_api_post(
"method.call/refreshOAuthService",
message='{"method": "refreshOAuthService", "params": []}',
)
assert response.ok
oauth_get = logged_rocket.settings_oauth().json()
assert oauth_get.get("success")
assert not oauth_get.get("services")
if oauth_get.get("services"):
# remove the OAuth app Test beforehand, when this is not the first test run (for reproducibility)
response = logged_rocket.call_api_post(
"method.call/removeOAuthService",
message='{"method": "removeOAuthService", "params": ["Test"]}',
)
assert response.ok
oauth_get = logged_rocket.settings_oauth().json()
assert not oauth_get.get("services")

oauth_set = logged_rocket.settings_addcustomoauth("Test").json()
assert oauth_set.get("success")
oauth_set = logged_rocket.settings_update("Accounts_OAuth_Custom-Test", True).json()
Expand Down

0 comments on commit 8003485

Please sign in to comment.