Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion linebot/models/flex_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ def __init__(self, size=None, direction=None, header=None, hero=None,
self.size = size
self.direction = direction
self.header = self.get_or_new_from_json_dict(header, BoxComponent)
self.hero = self.get_or_new_from_json_dict(hero, ImageComponent)
self.hero = self.get_or_new_from_json_dict_with_types(
hero, {
'image': ImageComponent,
'box': BoxComponent
}
)
self.body = self.get_or_new_from_json_dict(body, BoxComponent)
self.footer = self.get_or_new_from_json_dict(footer, BoxComponent)
self.styles = self.get_or_new_from_json_dict(styles, BubbleStyle)
Expand Down
17 changes: 11 additions & 6 deletions tests/models/test_flex_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ def test_bubble_container(self):
'header':
BoxComponent(layout='vertical',
contents=[TextComponent(text='Header text')]),
'hero':
ImageComponent(uri='https://example.com/flex/images/image.jpg'),
'body':
BoxComponent(layout='vertical',
contents=[TextComponent(text='Body text')]),
Expand All @@ -79,10 +77,17 @@ def test_bubble_container(self):
separator_color='#00ffff')
)
}
self.assertEqual(
self.serialize_as_dict(arg, type=self.BUBBLE),
BubbleContainer(**arg).as_json_dict()
)
heros = [
ImageComponent(uri='https://example.com/flex/images/image.jpg'),
BoxComponent(layout='vertical',
contents=[TextComponent(text='Body text')]),
]
for hero in heros:
arg['hero'] = hero
self.assertEqual(
self.serialize_as_dict(arg, type=self.BUBBLE),
BubbleContainer(**arg).as_json_dict()
)

def test_bubble_style(self):
arg = {
Expand Down