X Tutup
Skip to content

Commit 14ccbfa

Browse files
committed
Add type-safe builder tests
1 parent efc28ac commit 14ccbfa

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

tests/slack_bolt/context/test_ack.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from slack_sdk.models.blocks import PlainTextObject, DividerBlock
2+
from slack_sdk.models.views import View
3+
14
from slack_bolt import Ack, BoltResponse
25

36

@@ -72,3 +75,29 @@ def test_view_update(self):
7275
"}"
7376
"}",
7477
)
78+
79+
def test_view_update_2(self):
80+
ack = Ack()
81+
response: BoltResponse = ack(
82+
response_action="update",
83+
view=View(
84+
type="modal",
85+
callback_id="view-id",
86+
title=PlainTextObject(text="My App"),
87+
close=PlainTextObject(text="Cancel"),
88+
blocks=[DividerBlock(block_id="b")],
89+
),
90+
)
91+
assert (response.status, response.body) == (
92+
200,
93+
""
94+
'{"response_action": "update", '
95+
'"view": {'
96+
'"blocks": [{"block_id": "b", "type": "divider"}], '
97+
'"callback_id": "view-id", '
98+
'"close": {"text": "Cancel", "type": "plain_text"}, '
99+
'"title": {"text": "My App", "type": "plain_text"}, '
100+
'"type": "modal"'
101+
"}"
102+
"}",
103+
)

tests/slack_bolt_async/context/test_async_ack.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import pytest
2+
from slack_sdk.models.blocks import PlainTextObject, DividerBlock
3+
from slack_sdk.models.views import View
24

35
from slack_bolt import BoltResponse
46
from slack_bolt.context.ack.async_ack import AsyncAck
@@ -74,3 +76,30 @@ async def test_view_update(self):
7476
"}"
7577
"}",
7678
)
79+
80+
@pytest.mark.asyncio
81+
async def test_view_update_2(self):
82+
ack = AsyncAck()
83+
response: BoltResponse = await ack(
84+
response_action="update",
85+
view=View(
86+
type="modal",
87+
callback_id="view-id",
88+
title=PlainTextObject(text="My App"),
89+
close=PlainTextObject(text="Cancel"),
90+
blocks=[DividerBlock(block_id="b")],
91+
),
92+
)
93+
assert (response.status, response.body) == (
94+
200,
95+
""
96+
'{"response_action": "update", '
97+
'"view": {'
98+
'"blocks": [{"block_id": "b", "type": "divider"}], '
99+
'"callback_id": "view-id", '
100+
'"close": {"text": "Cancel", "type": "plain_text"}, '
101+
'"title": {"text": "My App", "type": "plain_text"}, '
102+
'"type": "modal"'
103+
"}"
104+
"}",
105+
)

0 commit comments

Comments
 (0)
X Tutup