Exemplo n.º 1
0
    def test_add_button_for_link(self):
        row = special_endpoints.ActionRowBuilder()
        button = row.add_button(messages.ButtonStyle.LINK, "go home")

        button.add_to_container()

        assert row.components == [button]
Exemplo n.º 2
0
    def test_add_select_menu(self):
        row = special_endpoints.ActionRowBuilder()
        menu = row.add_select_menu("hihihi")

        menu.add_to_container()

        assert row.components == [menu]
Exemplo n.º 3
0
    def test_build(self):
        mock_component_1 = mock.Mock()
        mock_component_2 = mock.Mock()

        row = special_endpoints.ActionRowBuilder()
        row._components = [mock_component_1, mock_component_2]

        result = row.build()

        assert result == {
            "type":
            messages.ComponentType.ACTION_ROW,
            "components": [
                mock_component_1.build.return_value,
                mock_component_2.build.return_value
            ],
        }
        mock_component_1.build.assert_called_once_with()
        mock_component_2.build.assert_called_once_with()
Exemplo n.º 4
0
 def test_components_property(self):
     mock_component = object()
     row = special_endpoints.ActionRowBuilder().add_component(
         mock_component)
     assert row.components == [mock_component]