File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from slack_sdk .models .blocks import PlanBlock , RichTextBlock , TaskCardBlock
2+ from slack_sdk .models .blocks .block_elements import (
3+ RichTextElementParts ,
4+ RichTextSectionElement ,
5+ )
6+
7+
8+ def example01 () -> PlanBlock :
9+ """
10+ Displays a plan with multiple task cards representing a sequence of actions.
11+ This is an experimental block type that requires a toggle to preview.
12+ https://docs.slack.dev/reference/block-kit/blocks/plan-block/
13+
14+ A plan block with multiple task cards in various states.
15+ """
16+ block = PlanBlock (
17+ title = "Thinking completed" ,
18+ tasks = [
19+ TaskCardBlock (
20+ task_id = "call_001" ,
21+ title = "Fetched user profile information" ,
22+ status = "in_progress" ,
23+ details = RichTextBlock (
24+ block_id = "viMWO" ,
25+ elements = [
26+ RichTextSectionElement (
27+ elements = [
28+ RichTextElementParts .Text (text = "Searched database..." )
29+ ]
30+ )
31+ ],
32+ ),
33+ output = RichTextBlock (
34+ block_id = "viMWO" ,
35+ elements = [
36+ RichTextSectionElement (
37+ elements = [
38+ RichTextElementParts .Text (text = "Profile data loaded" )
39+ ]
40+ )
41+ ],
42+ ),
43+ ),
44+ TaskCardBlock (
45+ task_id = "call_002" ,
46+ title = "Checked user permissions" ,
47+ status = "pending" ,
48+ ),
49+ TaskCardBlock (
50+ task_id = "call_003" ,
51+ title = "Generated comprehensive user report" ,
52+ status = "complete" ,
53+ output = RichTextBlock (
54+ block_id = "crsk" ,
55+ elements = [
56+ RichTextSectionElement (
57+ elements = [
58+ RichTextElementParts .Text (text = "15 data points compiled" )
59+ ]
60+ )
61+ ],
62+ ),
63+ ),
64+ ],
65+ )
66+ return block
Original file line number Diff line number Diff line change 1+ import json
2+
3+ from src .blocks import plan
4+
5+
6+ def test_example01 ():
7+ block = plan .example01 ()
8+ actual = block .to_dict ()
9+ expected = {
10+ "type" : "plan" ,
11+ "title" : "Thinking completed" ,
12+ "tasks" : [
13+ {
14+ "type" : "task_card" ,
15+ "task_id" : "call_001" ,
16+ "title" : "Fetched user profile information" ,
17+ "status" : "in_progress" ,
18+ "details" : {
19+ "type" : "rich_text" ,
20+ "block_id" : "viMWO" ,
21+ "elements" : [
22+ {
23+ "type" : "rich_text_section" ,
24+ "elements" : [
25+ {
26+ "type" : "text" ,
27+ "text" : "Searched database..." ,
28+ }
29+ ],
30+ }
31+ ],
32+ },
33+ "output" : {
34+ "type" : "rich_text" ,
35+ "block_id" : "viMWO" ,
36+ "elements" : [
37+ {
38+ "type" : "rich_text_section" ,
39+ "elements" : [
40+ {
41+ "type" : "text" ,
42+ "text" : "Profile data loaded" ,
43+ }
44+ ],
45+ }
46+ ],
47+ },
48+ },
49+ {
50+ "type" : "task_card" ,
51+ "task_id" : "call_002" ,
52+ "title" : "Checked user permissions" ,
53+ "status" : "pending" ,
54+ },
55+ {
56+ "type" : "task_card" ,
57+ "task_id" : "call_003" ,
58+ "title" : "Generated comprehensive user report" ,
59+ "status" : "complete" ,
60+ "output" : {
61+ "type" : "rich_text" ,
62+ "block_id" : "crsk" ,
63+ "elements" : [
64+ {
65+ "type" : "rich_text_section" ,
66+ "elements" : [
67+ {
68+ "type" : "text" ,
69+ "text" : "15 data points compiled" ,
70+ }
71+ ],
72+ }
73+ ],
74+ },
75+ },
76+ ],
77+ }
78+ assert json .dumps (actual , sort_keys = True ) == json .dumps (expected , sort_keys = True )
You can’t perform that action at this time.
0 commit comments