def test_create_card_key_value_with_icon(): expected = { "keyValue": { "topLabel": "Top Label", "content": "Content", "icon": "BUILT-IN ICON", } } assert (create_card_key_value("Top Label", "Content", icon="BUILT-IN ICON") == expected)
def test_create_card_key_value_with_bottom_label(): expected = { "keyValue": { "topLabel": "Top Label", "content": "Content", "bottomLabel": "Bottom Label", } } assert (create_card_key_value("Top Label", "Content", bottom_label="Bottom Label") == expected)
def test_create_card_key_value_with_on_click(): expected = { "keyValue": { "topLabel": "Top Label", "content": "Content", "onClick": { "openLink": { "url": "https://url.com" } }, } } assert (create_card_key_value("Top Label", "Content", on_click="https://url.com") == expected)
def test_create_cards_response_with_update_message(): header = create_card_header("Title", "Subtitle", "http://server.com/header.png") widgets = [ create_card_paragraph("Hello"), create_card_image("http://server.com/image.png"), ] card1 = create_card(widgets, header=header) card2 = create_card([ create_card_paragraph("World"), create_card_key_value("Label", "Content") ]) expected = { "actionResponse": { "type": "UPDATE_MESSAGE" }, "cards": [ { "header": { "title": "Title", "subtitle": "Subtitle", "imageUrl": "http://server.com/header.png", "imageStyle": "IMAGE", }, "sections": [{ "widgets": [ { "textParagraph": { "text": "Hello" } }, { "image": { "imageUrl": "http://server.com/image.png" } }, ] }], }, { "sections": [{ "widgets": [ { "textParagraph": { "text": "World" } }, { "keyValue": { "content": "Content", "topLabel": "Label" } }, ] }] }, ], } assert create_cards_response([card1, card2], update_message=True) == expected
def test_create_card_key_value(): expected = {"keyValue": {"topLabel": "Top Label", "content": "Content"}} assert create_card_key_value("Top Label", "Content") == expected
def test_create_card_key_value_with_invalid_content(): with pytest.raises(ValueError): create_card_key_value("Top Label", None)
def test_create_card_key_value_with_invalid_top_label(): with pytest.raises(ValueError): create_card_key_value(None, "Content")