Skip to content

Commit c8f2d6e

Browse files
authored
feat: accept assistant.threads.setStatus method arguments from the assistant class (#1371)
1 parent 973af99 commit c8f2d6e

File tree

9 files changed

+150
-14
lines changed

9 files changed

+150
-14
lines changed

docs/reference/async_app.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5248,11 +5248,18 @@ <h3>Class variables</h3>
52485248
self.channel_id = channel_id
52495249
self.thread_ts = thread_ts
52505250

5251-
async def __call__(self, status: str) -&gt; AsyncSlackResponse:
5251+
async def __call__(
5252+
self,
5253+
status: str,
5254+
loading_messages: Optional[List[str]] = None,
5255+
**kwargs,
5256+
) -&gt; AsyncSlackResponse:
52525257
return await self.client.assistant_threads_setStatus(
5253-
status=status,
52545258
channel_id=self.channel_id,
52555259
thread_ts=self.thread_ts,
5260+
status=status,
5261+
loading_messages=loading_messages,
5262+
**kwargs,
52565263
)</code></pre>
52575264
</details>
52585265
<div class="desc"></div>

docs/reference/context/set_status/async_set_status.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,18 @@ <h2 class="section-title" id="header-classes">Classes</h2>
7070
self.channel_id = channel_id
7171
self.thread_ts = thread_ts
7272

73-
async def __call__(self, status: str) -&gt; AsyncSlackResponse:
73+
async def __call__(
74+
self,
75+
status: str,
76+
loading_messages: Optional[List[str]] = None,
77+
**kwargs,
78+
) -&gt; AsyncSlackResponse:
7479
return await self.client.assistant_threads_setStatus(
75-
status=status,
7680
channel_id=self.channel_id,
7781
thread_ts=self.thread_ts,
82+
status=status,
83+
loading_messages=loading_messages,
84+
**kwargs,
7885
)</code></pre>
7986
</details>
8087
<div class="desc"></div>

docs/reference/context/set_status/index.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,18 @@ <h2 class="section-title" id="header-classes">Classes</h2>
8181
self.channel_id = channel_id
8282
self.thread_ts = thread_ts
8383

84-
def __call__(self, status: str) -&gt; SlackResponse:
84+
def __call__(
85+
self,
86+
status: str,
87+
loading_messages: Optional[List[str]] = None,
88+
**kwargs,
89+
) -&gt; SlackResponse:
8590
return self.client.assistant_threads_setStatus(
86-
status=status,
8791
channel_id=self.channel_id,
8892
thread_ts=self.thread_ts,
93+
status=status,
94+
loading_messages=loading_messages,
95+
**kwargs,
8996
)</code></pre>
9097
</details>
9198
<div class="desc"></div>

docs/reference/context/set_status/set_status.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,18 @@ <h2 class="section-title" id="header-classes">Classes</h2>
7070
self.channel_id = channel_id
7171
self.thread_ts = thread_ts
7272

73-
def __call__(self, status: str) -&gt; SlackResponse:
73+
def __call__(
74+
self,
75+
status: str,
76+
loading_messages: Optional[List[str]] = None,
77+
**kwargs,
78+
) -&gt; SlackResponse:
7479
return self.client.assistant_threads_setStatus(
75-
status=status,
7680
channel_id=self.channel_id,
7781
thread_ts=self.thread_ts,
82+
status=status,
83+
loading_messages=loading_messages,
84+
**kwargs,
7885
)</code></pre>
7986
</details>
8087
<div class="desc"></div>

docs/reference/index.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5786,11 +5786,18 @@ <h3>Class variables</h3>
57865786
self.channel_id = channel_id
57875787
self.thread_ts = thread_ts
57885788

5789-
def __call__(self, status: str) -&gt; SlackResponse:
5789+
def __call__(
5790+
self,
5791+
status: str,
5792+
loading_messages: Optional[List[str]] = None,
5793+
**kwargs,
5794+
) -&gt; SlackResponse:
57905795
return self.client.assistant_threads_setStatus(
5791-
status=status,
57925796
channel_id=self.channel_id,
57935797
thread_ts=self.thread_ts,
5798+
status=status,
5799+
loading_messages=loading_messages,
5800+
**kwargs,
57945801
)</code></pre>
57955802
</details>
57965803
<div class="desc"></div>

slack_bolt/context/set_status/async_set_status.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import List, Optional
2+
13
from slack_sdk.web.async_client import AsyncWebClient
24
from slack_sdk.web.async_slack_response import AsyncSlackResponse
35

@@ -17,9 +19,16 @@ def __init__(
1719
self.channel_id = channel_id
1820
self.thread_ts = thread_ts
1921

20-
async def __call__(self, status: str) -> AsyncSlackResponse:
22+
async def __call__(
23+
self,
24+
status: str,
25+
loading_messages: Optional[List[str]] = None,
26+
**kwargs,
27+
) -> AsyncSlackResponse:
2128
return await self.client.assistant_threads_setStatus(
22-
status=status,
2329
channel_id=self.channel_id,
2430
thread_ts=self.thread_ts,
31+
status=status,
32+
loading_messages=loading_messages,
33+
**kwargs,
2534
)

slack_bolt/context/set_status/set_status.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import List, Optional
2+
13
from slack_sdk import WebClient
24
from slack_sdk.web import SlackResponse
35

@@ -17,9 +19,16 @@ def __init__(
1719
self.channel_id = channel_id
1820
self.thread_ts = thread_ts
1921

20-
def __call__(self, status: str) -> SlackResponse:
22+
def __call__(
23+
self,
24+
status: str,
25+
loading_messages: Optional[List[str]] = None,
26+
**kwargs,
27+
) -> SlackResponse:
2128
return self.client.assistant_threads_setStatus(
22-
status=status,
2329
channel_id=self.channel_id,
2430
thread_ts=self.thread_ts,
31+
status=status,
32+
loading_messages=loading_messages,
33+
**kwargs,
2534
)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import pytest
2+
from slack_sdk import WebClient
3+
from slack_sdk.web import SlackResponse
4+
5+
from slack_bolt.context.set_status import SetStatus
6+
from tests.mock_web_api_server import cleanup_mock_web_api_server, setup_mock_web_api_server
7+
8+
9+
class TestSetStatus:
10+
def setup_method(self):
11+
setup_mock_web_api_server(self)
12+
valid_token = "xoxb-valid"
13+
mock_api_server_base_url = "http://localhost:8888"
14+
self.web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url)
15+
16+
def teardown_method(self):
17+
cleanup_mock_web_api_server(self)
18+
19+
def test_set_status(self):
20+
set_status = SetStatus(client=self.web_client, channel_id="C111", thread_ts="123.123")
21+
response: SlackResponse = set_status("Thinking...")
22+
assert response.status_code == 200
23+
24+
def test_set_status_loading_messages(self):
25+
set_status = SetStatus(client=self.web_client, channel_id="C111", thread_ts="123.123")
26+
response: SlackResponse = set_status(
27+
status="Thinking...",
28+
loading_messages=[
29+
"Sitting...",
30+
"Waiting...",
31+
],
32+
)
33+
assert response.status_code == 200
34+
35+
def test_set_status_invalid(self):
36+
set_status = SetStatus(client=self.web_client, channel_id="C111", thread_ts="123.123")
37+
with pytest.raises(TypeError):
38+
set_status()
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import pytest
2+
from slack_sdk.web.async_client import AsyncWebClient
3+
from slack_sdk.web.async_slack_response import AsyncSlackResponse
4+
5+
from slack_bolt.context.set_status.async_set_status import AsyncSetStatus
6+
from tests.mock_web_api_server import cleanup_mock_web_api_server_async, setup_mock_web_api_server_async
7+
from tests.utils import get_event_loop
8+
9+
10+
class TestAsyncSetStatus:
11+
@pytest.fixture
12+
def event_loop(self):
13+
setup_mock_web_api_server_async(self)
14+
valid_token = "xoxb-valid"
15+
mock_api_server_base_url = "http://localhost:8888"
16+
self.web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url)
17+
18+
loop = get_event_loop()
19+
yield loop
20+
loop.close()
21+
cleanup_mock_web_api_server_async(self)
22+
23+
@pytest.mark.asyncio
24+
async def test_set_status(self):
25+
set_status = AsyncSetStatus(client=self.web_client, channel_id="C111", thread_ts="123.123")
26+
response: AsyncSlackResponse = await set_status("Thinking...")
27+
assert response.status_code == 200
28+
29+
@pytest.mark.asyncio
30+
async def test_set_status_loading_messages(self):
31+
set_status = AsyncSetStatus(client=self.web_client, channel_id="C111", thread_ts="123.123")
32+
response: AsyncSlackResponse = await set_status(
33+
status="Thinking...",
34+
loading_messages=[
35+
"Sitting...",
36+
"Waiting...",
37+
],
38+
)
39+
assert response.status_code == 200
40+
41+
@pytest.mark.asyncio
42+
async def test_set_status_invalid(self):
43+
set_status = AsyncSetStatus(client=self.web_client, channel_id="C111", thread_ts="123.123")
44+
with pytest.raises(TypeError):
45+
await set_status()

0 commit comments

Comments
 (0)