]> git.cworth.org Git - turbot/blob - turbot/util/blocks-test.py
2e09c0ec177f889cb4c9bb9295ed67d4d55eba85
[turbot] / turbot / util / blocks-test.py
1 #!/usr/bin/env python3
2
3 from blocks import (
4     multi_select_block, accessory_block, section_block, text_block
5 )
6
7 def new_multi_select_block(label, name, placeholder, options, default=None):
8
9     multi_select = {
10         "action_id": name,
11         "type": "multi_static_select",
12         "placeholder": {
13             "type": "plain_text",
14             "text": placeholder
15         },
16         "options": [
17             {
18                 "text": {
19                     "type": "plain_text",
20                     "text": option
21                 },
22                 "value": option
23             } for option in options
24         ]
25     }
26
27     return accessory_block(
28         section_block(text_block("*{}*".format(label))),
29         multi_select
30     )
31
32 blocks = multi_select_block("Label", "Name", "Placeholder",
33                             ["Foo", "Bar", "Baz"])
34
35 blocks_str = str(blocks)
36
37 new_blocks = new_multi_select_block("Label", "Name", "Placeholder",
38                                     ["Foo", "Bar", "Baz"])
39
40 new_blocks_str = str(new_blocks)
41
42 print("In main, blocks is: {}".format(blocks_str))
43
44 print("Also new_blocks is: {}".format(new_blocks_str))
45
46 if blocks_str == new_blocks_str:
47     print("Perfect match!")
48 else:
49     print("No match.")