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 }
def confirm(values, plain_text, markdown_text): return Confirm( plain_text, markdown_text, PlainText(values.confirm_text), PlainText(values.deny_text), )
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, }
def modal_text(values): return PlainText("Action")
def plain_text(values): return PlainText(values.text)
def short_text(values): return PlainText(values.short_text)
def test_array_field_validatates_strings(values): texts = [values.text] assert ArrayField(Text).validate(texts) == [ PlainText(values.text, emoji=True) ]
def test_array_field_validates_input(values): texts = [PlainText(values.text) for _ in range(3)] assert ArrayField(PlainText).validate(texts)
def test_text_field_with_exeeding_length_raises_exception(): with pytest.raises(ValidationError): TextField(max_length=5).validate(PlainText("foobar"))
def test_text_field_validates_str_input(plain, values): text = "Hey there!" assert TextField(plain=plain).validate(text) == PlainText(text, emoji=True)
def test_text_field_validates_input(values): text = PlainText(values.text) assert TextField().validate(text) == text