3939 VideoBlock ,
4040)
4141from slack_sdk .models .blocks .basic_components import FeedbackButtonObject , SlackFile
42- from slack_sdk .models .blocks .block_elements import FeedbackButtonsElement , IconButtonElement
42+ from slack_sdk .models .blocks .block_elements import FeedbackButtonsElement , IconButtonElement , ImageElement
4343
4444from . import STRING_3001_CHARS
4545
@@ -1560,10 +1560,14 @@ class CardBlockTests(unittest.TestCase):
15601560 def test_document (self ):
15611561 input = {
15621562 "type" : "card" ,
1563- "icon" : " https://picsum.photos/36/36" ,
1563+ "icon" : { "type" : "image" , "image_url" : " https://picsum.photos/36/36", "alt_text" : "Icon" } ,
15641564 "title" : {"type" : "mrkdwn" , "text" : "Lumon Industries" , "verbatim" : False },
15651565 "subtitle" : {"type" : "mrkdwn" , "text" : "Committed to work-life balance" , "verbatim" : False },
1566- "hero_image" : "https://picsum.photos/400/300" ,
1566+ "hero_image" : {
1567+ "type" : "image" ,
1568+ "image_url" : "https://picsum.photos/400/300" ,
1569+ "alt_text" : "Sample hero image" ,
1570+ },
15671571 "body" : {"type" : "mrkdwn" , "text" : "Please enjoy each card equally." , "verbatim" : False },
15681572 "actions" : [
15691573 {
@@ -1575,6 +1579,24 @@ def test_document(self):
15751579 }
15761580 self .assertDictEqual (input , CardBlock (** input ).to_dict ())
15771581
1582+ def test_image_element_icon_and_hero_image (self ):
1583+ block = CardBlock (
1584+ icon = ImageElement (image_url = "https://picsum.photos/36/36" , alt_text = "Icon" ),
1585+ hero_image = ImageElement (image_url = "https://picsum.photos/400/300" , alt_text = "Sample hero image" ),
1586+ title = MarkdownTextObject (text = "Lumon Industries" ),
1587+ )
1588+ expected = {
1589+ "type" : "card" ,
1590+ "icon" : {"type" : "image" , "image_url" : "https://picsum.photos/36/36" , "alt_text" : "Icon" },
1591+ "hero_image" : {
1592+ "type" : "image" ,
1593+ "image_url" : "https://picsum.photos/400/300" ,
1594+ "alt_text" : "Sample hero image" ,
1595+ },
1596+ "title" : {"type" : "mrkdwn" , "text" : "Lumon Industries" },
1597+ }
1598+ self .assertDictEqual (expected , block .to_dict ())
1599+
15781600 def test_parse (self ):
15791601 input = {
15801602 "type" : "card" ,
0 commit comments