Exemplo n.º 1
0
 def button(self):
     return special_endpoints._ButtonBuilder(
         container=mock.Mock(),
         style=messages.ButtonStyle.DANGER,
         custom_id="sfdasdasd",
         url="hi there",
         emoji=543123,
         emoji_id="56554456",
         emoji_name="hi there",
         label="a lebel",
         is_disabled=True,
     )
Exemplo n.º 2
0
    def test_add_to_container(self):
        mock_container = mock.Mock()
        button = special_endpoints._ButtonBuilder(
            container=mock_container,
            style=messages.ButtonStyle.DANGER,
            url=undefined.UNDEFINED,
            emoji_id=undefined.UNDEFINED,
            emoji_name="emoji_name",
            label="no u",
            custom_id="ooga booga",
            is_disabled=True,
        )

        assert button.add_to_container() is mock_container

        mock_container.add_component.assert_called_once_with(button)
Exemplo n.º 3
0
    def test_build_without_optional_fields(self):
        result = special_endpoints._ButtonBuilder(
            container=object(),
            style=messages.ButtonStyle.LINK,
            url="OK",
            emoji_id="123321",
            emoji_name=undefined.UNDEFINED,
            label=undefined.UNDEFINED,
            custom_id=undefined.UNDEFINED,
            is_disabled=False,
        ).build()

        assert result == {
            "type": messages.ComponentType.BUTTON,
            "style": messages.ButtonStyle.LINK,
            "emoji": {
                "id": "123321"
            },
            "disabled": False,
            "url": "OK",
        }
Exemplo n.º 4
0
    def test_build(self):
        result = special_endpoints._ButtonBuilder(
            container=object(),
            style=messages.ButtonStyle.DANGER,
            url=undefined.UNDEFINED,
            emoji_id=undefined.UNDEFINED,
            emoji_name="emoji_name",
            label="no u",
            custom_id="ooga booga",
            is_disabled=True,
        ).build()

        assert result == {
            "type": messages.ComponentType.BUTTON,
            "style": messages.ButtonStyle.DANGER,
            "emoji": {
                "name": "emoji_name"
            },
            "label": "no u",
            "custom_id": "ooga booga",
            "disabled": True,
        }