コード例 #1
0
def test_builds_plain_text_with_emoji(values):
    text = PlainText(values.text, emoji=True)
    assert text.build() == {
        "type": Text.plain,
        "text": values.text,
        "emoji": True
    }
コード例 #2
0
def confirm(values, plain_text, markdown_text):
    return Confirm(
        plain_text,
        markdown_text,
        PlainText(values.confirm_text),
        PlainText(values.deny_text),
    )
コード例 #3
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,
    }
コード例 #4
0
def modal_text(values):
    return PlainText("Action")
コード例 #5
0
def plain_text(values):
    return PlainText(values.text)
コード例 #6
0
def short_text(values):
    return PlainText(values.short_text)
コード例 #7
0
def test_array_field_validatates_strings(values):
    texts = [values.text]
    assert ArrayField(Text).validate(texts) == [
        PlainText(values.text, emoji=True)
    ]
コード例 #8
0
def test_array_field_validates_input(values):
    texts = [PlainText(values.text) for _ in range(3)]
    assert ArrayField(PlainText).validate(texts)
コード例 #9
0
def test_text_field_with_exeeding_length_raises_exception():
    with pytest.raises(ValidationError):
        TextField(max_length=5).validate(PlainText("foobar"))
コード例 #10
0
def test_text_field_validates_str_input(plain, values):
    text = "Hey there!"
    assert TextField(plain=plain).validate(text) == PlainText(text, emoji=True)
コード例 #11
0
def test_text_field_validates_input(values):
    text = PlainText(values.text)
    assert TextField().validate(text) == text