Ejemplo n.º 1
0
def view_attributes():
    return {
        "blocks": [PlainText("text")],
        "private_metadata": '{"data": "OK"}',
        "callback_id": "callback_id",
        "external_id": "external_id",
    }
Ejemplo n.º 2
0
 def _make_confirm():
     return ConfirmationDialog(
         text_object=PlainText("text"),
         title="title",
         confirm="confirm",
         deny="deny",
     )
Ejemplo n.º 3
0
class MockFixedButton(FixedButton):
    action_id = "test_action"
    text = "text"
    value = "value"
    url = "http://crispy.dev"
    confirm = ConfirmationDialog(
        text_object=PlainText("text"),
        title="title",
        confirm="confirm",
        deny="deny",
    )
    style = Button.Styles.DEFAULT
Ejemplo n.º 4
0
class TestFixedButton:
    def test_fixed(self, snapshot):
        snapshot.assert_match(MockFixedButton())

    @pytest.mark.parametrize(
        "field, value",
        [
            ("action_id", "override"),
            ("value", "override"),
            (
                "confirm",
                ConfirmationDialog(
                    text_object=PlainText("override"),
                    title="override",
                    confirm="confirm",
                    deny="deny",
                ),
            ),
            ("text", "override"),
            ("style", Button.Styles.DANGER),
        ],
    )
    def test_override(self, snapshot, field, value):
        snapshot.assert_match(MockFixedButton(**{field: value}))
Ejemplo n.º 5
0
 def test_validate_elements(self):
     with pytest.raises(ValidationError):
         Context(elements=[PlainText(str(i)) for i in range(11)])
Ejemplo n.º 6
0
 def test(self, snapshot):
     snapshot.assert_match(
         Context(block_id="block_id", elements=[PlainText("text")]))
Ejemplo n.º 7
0
 def test_validate_fields(self, attributes):
     del attributes["text_object"]
     attributes["fields"] = [PlainText(str(i)) for i in range(11)]
     with pytest.raises(ValidationError):
         Section(**attributes)
Ejemplo n.º 8
0
 def test_fields(self, attributes, snapshot):
     del attributes["text_object"]
     attributes["fields"] = [PlainText("text")]
     snapshot.assert_match(Section(**attributes))
Ejemplo n.º 9
0
 def attributes(self):
     return {
         "block_id": "block_id",
         "text_object": PlainText("text"),
         "accessory": MockElement(),
     }