Ejemplo n.º 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,
        )
Ejemplo n.º 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,
        )
Ejemplo n.º 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,
        )
Ejemplo n.º 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,
        )
Ejemplo n.º 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,
        )
Ejemplo n.º 6
0
class ExternalSelectBase(Select):
    min_query_length = IntegerField()
Ejemplo n.º 7
0
def test_integer_field_with_exceeding_value_raises_exception():
    with pytest.raises(ValidationError):
        IntegerField(max_value=10).validate(11)
Ejemplo n.º 8
0
def test_integer_field_with_incorrect_input_raises_exception():
    with pytest.raises(ValidationError):
        IntegerField().validate("one")
Ejemplo n.º 9
0
def test_integer_field_validates_input():
    assert IntegerField().validate(1)