Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions docs/reference/async_app.html
Original file line number Diff line number Diff line change
Expand Up @@ -5248,11 +5248,18 @@ <h3>Class variables</h3>
self.channel_id = channel_id
self.thread_ts = thread_ts

async def __call__(self, status: str) -&gt; AsyncSlackResponse:
async def __call__(
self,
status: str,
loading_messages: Optional[List[str]] = None,
**kwargs,
) -&gt; AsyncSlackResponse:
return await self.client.assistant_threads_setStatus(
status=status,
channel_id=self.channel_id,
thread_ts=self.thread_ts,
status=status,
loading_messages=loading_messages,
**kwargs,
)</code></pre>
</details>
<div class="desc"></div>
Expand Down
11 changes: 9 additions & 2 deletions docs/reference/context/set_status/async_set_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,18 @@ <h2 class="section-title" id="header-classes">Classes</h2>
self.channel_id = channel_id
self.thread_ts = thread_ts

async def __call__(self, status: str) -&gt; AsyncSlackResponse:
async def __call__(
self,
status: str,
loading_messages: Optional[List[str]] = None,
**kwargs,
) -&gt; AsyncSlackResponse:
return await self.client.assistant_threads_setStatus(
status=status,
channel_id=self.channel_id,
thread_ts=self.thread_ts,
status=status,
loading_messages=loading_messages,
**kwargs,
)</code></pre>
</details>
<div class="desc"></div>
Expand Down
11 changes: 9 additions & 2 deletions docs/reference/context/set_status/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,18 @@ <h2 class="section-title" id="header-classes">Classes</h2>
self.channel_id = channel_id
self.thread_ts = thread_ts

def __call__(self, status: str) -&gt; SlackResponse:
def __call__(
self,
status: str,
loading_messages: Optional[List[str]] = None,
**kwargs,
) -&gt; SlackResponse:
return self.client.assistant_threads_setStatus(
status=status,
channel_id=self.channel_id,
thread_ts=self.thread_ts,
status=status,
loading_messages=loading_messages,
**kwargs,
)</code></pre>
</details>
<div class="desc"></div>
Expand Down
11 changes: 9 additions & 2 deletions docs/reference/context/set_status/set_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,18 @@ <h2 class="section-title" id="header-classes">Classes</h2>
self.channel_id = channel_id
self.thread_ts = thread_ts

def __call__(self, status: str) -&gt; SlackResponse:
def __call__(
self,
status: str,
loading_messages: Optional[List[str]] = None,
**kwargs,
) -&gt; SlackResponse:
return self.client.assistant_threads_setStatus(
status=status,
channel_id=self.channel_id,
thread_ts=self.thread_ts,
status=status,
loading_messages=loading_messages,
**kwargs,
)</code></pre>
</details>
<div class="desc"></div>
Expand Down
11 changes: 9 additions & 2 deletions docs/reference/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5786,11 +5786,18 @@ <h3>Class variables</h3>
self.channel_id = channel_id
self.thread_ts = thread_ts

def __call__(self, status: str) -&gt; SlackResponse:
def __call__(
self,
status: str,
loading_messages: Optional[List[str]] = None,
**kwargs,
) -&gt; SlackResponse:
return self.client.assistant_threads_setStatus(
status=status,
channel_id=self.channel_id,
thread_ts=self.thread_ts,
status=status,
loading_messages=loading_messages,
**kwargs,
)</code></pre>
</details>
<div class="desc"></div>
Expand Down
13 changes: 11 additions & 2 deletions slack_bolt/context/set_status/async_set_status.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import List, Optional

from slack_sdk.web.async_client import AsyncWebClient
from slack_sdk.web.async_slack_response import AsyncSlackResponse

Expand All @@ -17,9 +19,16 @@ def __init__(
self.channel_id = channel_id
self.thread_ts = thread_ts

async def __call__(self, status: str) -> AsyncSlackResponse:
async def __call__(
self,
status: str,
loading_messages: Optional[List[str]] = None,
**kwargs,
) -> AsyncSlackResponse:
return await self.client.assistant_threads_setStatus(
status=status,
channel_id=self.channel_id,
thread_ts=self.thread_ts,
status=status,
loading_messages=loading_messages,
**kwargs,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

priaise: The **kwargs is a nice touch to add some future proofing for additional arguments. 🆗

)
13 changes: 11 additions & 2 deletions slack_bolt/context/set_status/set_status.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import List, Optional

from slack_sdk import WebClient
from slack_sdk.web import SlackResponse

Expand All @@ -17,9 +19,16 @@ def __init__(
self.channel_id = channel_id
self.thread_ts = thread_ts

def __call__(self, status: str) -> SlackResponse:
def __call__(
self,
status: str,
loading_messages: Optional[List[str]] = None,
**kwargs,
) -> SlackResponse:
return self.client.assistant_threads_setStatus(
status=status,
channel_id=self.channel_id,
thread_ts=self.thread_ts,
status=status,
loading_messages=loading_messages,
**kwargs,
)
38 changes: 38 additions & 0 deletions tests/slack_bolt/context/test_set_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import pytest
from slack_sdk import WebClient
from slack_sdk.web import SlackResponse

from slack_bolt.context.set_status import SetStatus
from tests.mock_web_api_server import cleanup_mock_web_api_server, setup_mock_web_api_server


class TestSetStatus:
def setup_method(self):
setup_mock_web_api_server(self)
valid_token = "xoxb-valid"
mock_api_server_base_url = "http://localhost:8888"
self.web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url)

def teardown_method(self):
cleanup_mock_web_api_server(self)

def test_set_status(self):
set_status = SetStatus(client=self.web_client, channel_id="C111", thread_ts="123.123")
response: SlackResponse = set_status("Thinking...")
assert response.status_code == 200

def test_set_status_loading_messages(self):
set_status = SetStatus(client=self.web_client, channel_id="C111", thread_ts="123.123")
response: SlackResponse = set_status(
status="Thinking...",
loading_messages=[
"Sitting...",
"Waiting...",
],
)
assert response.status_code == 200

def test_set_status_invalid(self):
set_status = SetStatus(client=self.web_client, channel_id="C111", thread_ts="123.123")
with pytest.raises(TypeError):
set_status()
45 changes: 45 additions & 0 deletions tests/slack_bolt_async/context/test_async_set_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import pytest
from slack_sdk.web.async_client import AsyncWebClient
from slack_sdk.web.async_slack_response import AsyncSlackResponse

from slack_bolt.context.set_status.async_set_status import AsyncSetStatus
from tests.mock_web_api_server import cleanup_mock_web_api_server_async, setup_mock_web_api_server_async
from tests.utils import get_event_loop


class TestAsyncSetStatus:
@pytest.fixture
def event_loop(self):
setup_mock_web_api_server_async(self)
valid_token = "xoxb-valid"
mock_api_server_base_url = "http://localhost:8888"
self.web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url)

loop = get_event_loop()
yield loop
loop.close()
cleanup_mock_web_api_server_async(self)

@pytest.mark.asyncio
async def test_set_status(self):
set_status = AsyncSetStatus(client=self.web_client, channel_id="C111", thread_ts="123.123")
response: AsyncSlackResponse = await set_status("Thinking...")
assert response.status_code == 200

@pytest.mark.asyncio
async def test_set_status_loading_messages(self):
set_status = AsyncSetStatus(client=self.web_client, channel_id="C111", thread_ts="123.123")
response: AsyncSlackResponse = await set_status(
status="Thinking...",
loading_messages=[
"Sitting...",
"Waiting...",
],
)
assert response.status_code == 200

@pytest.mark.asyncio
async def test_set_status_invalid(self):
set_status = AsyncSetStatus(client=self.web_client, channel_id="C111", thread_ts="123.123")
with pytest.raises(TypeError):
await set_status()
Loading