Exemplo n.º 1
0
def test_card_draw_form_slider_with_step():
    """
    Ensure the expected form widget and associated label are added to the
    screen's layout instance.
    """
    card = Card(
        "title", form=Inputs.SLIDER, text="Form label...", options=(1, 100, 10)
    )
    card.layout = mock.MagicMock()
    card.font_size = "48sp"
    card._draw_form()
    assert card.form_label.text == "Form label..."
    assert card.form_label.font_size == 48.0
    assert card.form_label.markup is True
    assert card.form_label.color == [1.0, 1.0, 1.0, 1.0]
    assert card.form_label.valign == "top"
    assert card.form_label.halign == "left"
    assert card.slider_label.text == "0"
    assert card.slider_label.font_size == 64.0
    assert card.slider.min == 1
    assert card.slider.max == 100
    assert card.slider.step == 10
    assert card.slider.value_track is True
Exemplo n.º 2
0
def test_card_draw_buttons():
    """
    Ensure the expected buttons are created and linked to an event handler.
    """
    card = Card("title",
                buttons=[{
                    "label": "Button1",
                    "target": "AnotherCard"
                }])
    card.layout = mock.MagicMock()
    card._button_click = mock.MagicMock()
    card._draw_buttons()
    assert len(card.button_widgets) == 1
    assert card.button_widgets[0].text == "Button1"
    assert card.button_widgets[0].color == [1.0, 1.0, 1.0, 1.0]  # white.
    assert card.button_widgets[0].background_color == [
        0.7450980392156863,
        0.7450980392156863,
        0.7450980392156863,
        1.0,
    ]  # grey.
    assert card.button_widgets[0].font_size == 24.0
    card._button_click.assert_called_once_with("AnotherCard")
    assert card.layout.add_widget.call_count == 1
Exemplo n.º 3
0
def test_card_form_value_no_form():
    """
    Must return None if there is no form associated with the card.
    """
    card = Card("title")
    assert card.form_value() is None