Skip to content

Commit bd9886c

Browse files
committed
test: confirm plan and task_card json is parsed as expected blocks
1 parent 7a61bbf commit bd9886c

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

tests/slack_sdk/models/test_blocks.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
Option,
2222
OverflowMenuElement,
2323
PlainTextObject,
24+
PlanBlock,
2425
RawTextObject,
2526
RichTextBlock,
2627
RichTextElementParts,
@@ -31,6 +32,7 @@
3132
SectionBlock,
3233
StaticSelectElement,
3334
TableBlock,
35+
TaskCardBlock,
3436
VideoBlock,
3537
)
3638
from slack_sdk.models.blocks.basic_components import FeedbackButtonObject, SlackFile
@@ -890,6 +892,87 @@ def test_text_length_12001(self):
890892
MarkdownBlock(**input).validate_json()
891893

892894

895+
# ----------------------------------------------
896+
# Plan
897+
# ----------------------------------------------
898+
899+
900+
class PlanBlockTests(unittest.TestCase):
901+
def test_document(self):
902+
input = {
903+
"type": "plan",
904+
"plan_id": "plan_1",
905+
"title": "Thinking completed",
906+
"tasks": [
907+
{
908+
"task_id": "call_001",
909+
"title": "Fetched user profile information",
910+
"status": "in_progress",
911+
"details": {
912+
"type": "rich_text",
913+
"elements": [
914+
{"type": "rich_text_section", "elements": [{"type": "text", "text": "Searched database..."}]}
915+
],
916+
},
917+
"output": {
918+
"type": "rich_text",
919+
"elements": [
920+
{"type": "rich_text_section", "elements": [{"type": "text", "text": "Profile data loaded"}]}
921+
],
922+
},
923+
},
924+
{
925+
"task_id": "call_002",
926+
"title": "Checked user permissions",
927+
"status": "pending",
928+
},
929+
{
930+
"task_id": "call_003",
931+
"title": "Generated comprehensive user report",
932+
"status": "complete",
933+
"output": {
934+
"type": "rich_text",
935+
"elements": [
936+
{"type": "rich_text_section", "elements": [{"type": "text", "text": "15 data points compiled"}]}
937+
],
938+
},
939+
},
940+
],
941+
}
942+
self.assertDictEqual(input, PlanBlock(**input).to_dict())
943+
self.assertDictEqual(input, Block.parse(input).to_dict())
944+
945+
946+
# ----------------------------------------------
947+
# Task card
948+
# ----------------------------------------------
949+
950+
951+
class TaskCardBlockTests(unittest.TestCase):
952+
def test_document(self):
953+
input = {
954+
"type": "task_card",
955+
"task_id": "task_1",
956+
"title": "Fetching weather data",
957+
"status": "pending",
958+
"output": {
959+
"type": "rich_text",
960+
"elements": [
961+
{
962+
"type": "rich_text_section",
963+
"elements": [{"type": "text", "text": "Found weather data for Chicago from 2 sources"}],
964+
}
965+
],
966+
},
967+
"sources": [
968+
{"type": "url", "url": "https://weather.com/", "text": "weather.com"},
969+
{"type": "url", "url": "https://www.accuweather.com/", "text": "accuweather.com"},
970+
],
971+
}
972+
self.assertDictEqual(input, TaskCardBlock(**input).to_dict())
973+
self.assertDictEqual(input, Block.parse(input).to_dict())
974+
975+
893976
# ----------------------------------------------
894977
# Video
895978
# ----------------------------------------------

0 commit comments

Comments
 (0)