Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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
Пример #4
0
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
Пример #5
0
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)
Пример #6
0
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")
Пример #7
0
def test_create_card_text_button_with_invalid_arguments(args):
    with pytest.raises(ValueError):
        create_card_text_button(args)