def test_create_card_buttons(): expected = { "buttons": [ { "textButton": { "text": "Link", "onClick": { "openLink": { "url": "https://server.com" } }, } }, { "textButton": { "text": "Action", "onClick": { "action": { "actionMethodName": "my-action" } }, } }, ] } assert (create_card_buttons([ create_card_text_button("Link", link="https://server.com"), create_card_text_button("Action", action="my-action"), ]) == expected)
def test_create_card_text_button_with_action_and_params(): expected = { "textButton": { "text": "Text", "onClick": { "action": { "actionMethodName": "my-action", "parameters": [ { "key": "id", "value": "jane" }, { "key": "name", "value": "Jane Doe" }, ], } }, } } assert (create_card_text_button("Text", action="my-action", params={ "id": "jane", "name": "Jane Doe" }) == expected)
def test_create_card_text_button_with_action(): expected = { "textButton": { "text": "Text", "onClick": { "action": { "actionMethodName": "my-action" } }, } } assert create_card_text_button("Text", action="my-action") == expected
def test_create_card_text_button_with_link(): expected = { "textButton": { "text": "Text", "onClick": { "openLink": { "url": "https://server.com" } }, } } assert create_card_text_button("Text", link="https://server.com") == expected
def test_create_card_text_button_with_action_and_invalid_params(params): with pytest.raises(TypeError): create_card_text_button("Text", action="action", params=params)
def test_create_card_text_button_with_link_and_action(): with pytest.raises(ValueError): create_card_text_button("Text", link="https://server.com", action="action")
def test_create_card_text_button_with_invalid_arguments(args): with pytest.raises(ValueError): create_card_text_button(args)