Example #1
0
class PlainTextInput(ActionableElement):
    placeholder = TextField(plain=True, max_length=150)
    initial_value = StringField()
    multiline = BooleanField()
    min_length = IntegerField(max_value=3000)
    max_length = IntegerField()

    def __init__(
        self,
        action_id,
        placeholder=None,
        initial_value=None,
        multiline=None,
        min_length=None,
        max_length=None,
    ):
        super().__init__(
            "plain_text_input",
            action_id,
            placeholder,
            initial_value,
            multiline,
            min_length,
            max_length,
        )
Example #2
0
class MultiStaticSelect(StaticSelectBase):
    initial_options = ArrayField(Option, OptionGroup, max_items=100)
    max_selected_items = IntegerField()

    def __init__(
        self,
        placeholder,
        action_id,
        options=None,
        option_groups=None,
        initial_options=None,
        confirm=None,
        max_selected_items=None,
    ):
        if options and option_groups:
            raise ValidationError("You can specify either options or option_groups.")

        super().__init__(
            "multi_static_select",
            action_id,
            placeholder,
            confirm,
            options,
            option_groups,
            initial_options,
            max_selected_items,
        )
Example #3
0
class MultiConversationsSelect(Select):
    initial_conversations = ArrayField(str)
    default_to_current_conversation = BooleanField()
    max_selected_items = IntegerField()
    filter = ObjectField(Filter)

    def __init__(
        self,
        placeholder,
        action_id,
        initial_conversations=None,
        default_to_current_conversation=None,
        confirm=None,
        max_selected_items=None,
        filter=None,
    ):
        super().__init__(
            "multi_conversations_select",
            action_id,
            placeholder,
            confirm,
            initial_conversations,
            default_to_current_conversation,
            max_selected_items,
            filter,
        )
Example #4
0
class MultiChannelsSelect(Select):
    initial_channels = ArrayField(str)
    max_selected_items = IntegerField()

    def __init__(
        self,
        placeholder,
        action_id,
        initial_channels=None,
        confirm=None,
        max_selected_items=None,
    ):
        super().__init__(
            "multi_channels_select",
            action_id,
            placeholder,
            confirm,
            initial_channels,
            max_selected_items,
        )
Example #5
0
class MultiExternalSelect(ExternalSelectBase):
    initial_options = ArrayField(Option, OptionGroup, max_items=100)
    max_selected_items = IntegerField()

    def __init__(
        self,
        placeholder,
        action_id,
        min_query_length=None,
        initial_options=None,
        confirm=None,
        max_selected_items=None,
    ):
        super().__init__(
            "multi_external_select",
            action_id,
            placeholder,
            confirm,
            min_query_length,
            initial_options,
            max_selected_items,
        )
Example #6
0
class ExternalSelectBase(Select):
    min_query_length = IntegerField()
Example #7
0
def test_integer_field_with_exceeding_value_raises_exception():
    with pytest.raises(ValidationError):
        IntegerField(max_value=10).validate(11)
Example #8
0
def test_integer_field_with_incorrect_input_raises_exception():
    with pytest.raises(ValidationError):
        IntegerField().validate("one")
Example #9
0
def test_integer_field_validates_input():
    assert IntegerField().validate(1)