Esempio n. 1
0
def test_component_builds_fields(values):
    class ParentFakeComponent(Component):
        title = StringField()
        text = TextField()

    class FakeComponent(ParentFakeComponent):
        elements = ArrayField(PlainText)
        users = ArrayField(str)

    users = ["U123456", "U654321"]
    component = FakeComponent(
        values.title,
        MarkdownText(values.text),
        [PlainText(values.text) for _ in range(2)],
        users,
    )

    assert component.build() == {
        "title":
        values.title,
        "text": {
            "type": "mrkdwn",
            "text": values.text
        },
        "elements": [
            {
                "type": "plain_text",
                "text": values.text
            },
            {
                "type": "plain_text",
                "text": values.text
            },
        ],
        "users":
        users,
    }
Esempio n. 2
0
from blockkit import Message, Section, Actions, MarkdownText, Button

message = Message(blocks=[
    Section(MarkdownText("You have a new request")),
    Section(fields=[
        MarkdownText("*Type:*\nComputer (laptop)"),
        MarkdownText("*When:*\nSubmitted Aut 10"),
        MarkdownText("*Last Update:*\nMar 10, 2015 (3 years, 5 months)"),
        MarkdownText("*Reason:*\nAll vowel keys aren't working."),
        MarkdownText("*Specs:*\nCheetah Pro 15 - Fast, really fast"),
    ], ),
    Actions([
        Button("Approve", style=Button.primary, action_id="approve"),
        Button("Decline", style=Button.danger, action_id="decline"),
        Button("Discuss", action_id="discuss"),
    ]),
])

message = message.build()
Esempio n. 3
0
def markdown_text(values):
    return MarkdownText(values.text)
Esempio n. 4
0
def test_builds_markdown_text(values):
    assert MarkdownText(values.text, verbatim=True).build() == {
        "type": Text.markdown,
        "text": values.text,
        "verbatim": True,
    }
Esempio n. 5
0
def test_plain_text_field_with_incorrect_type_raises_exception(values):
    with pytest.raises(ValidationError):
        TextField(plain=True).validate(MarkdownText(values.text))