Пример #1
0
def confirm_object() -> ConfirmObject:
    return ConfirmObject(
        title=PlainTextObject(text="Confirmation"),
        text=PlainTextObject(text="Confirmation"),
        confirm=PlainTextObject(text="Confirm"),
        deny=PlainTextObject(text="Deny"),
    )
Пример #2
0
def actions_block() -> ActionsBlock:
    return ActionsBlock(
        elements=[
            RadioButtonGroupElement(
                action_id="action-block",
                options=[
                    OptionObject(
                        PlainTextObject(text="Action block 1"), value="action1"
                    ),
                    OptionObject(
                        PlainTextObject(text="Action block 2"), value="action2"
                    ),
                ],
            ),
            PlainTextInputElement(
                action_id="input1",
                placeholder=PlainTextObject(text="Input"),
                initial_value="Input",
            ),
            OverflowElement(
                action_id="overflow1",
                options=[
                    OptionObject(
                        PlainTextObject(text="Overflow block 1"), value="overflow1"
                    ),
                    OptionObject(
                        PlainTextObject(text="Overflow block 2"), value="overflow2"
                    ),
                ],
            ),
        ]
    )
Пример #3
0
def input_block() -> InputBlock:
    return InputBlock(
        label=PlainTextObject(text="Input Block"),
        element=ButtonElement(text=PlainTextObject(text="Element"),
                              action_id="element1"),
        hint=PlainTextObject(text="This is a hint"),
        optional=True,
    )
Пример #4
0
def datepicker_element() -> DatepickerElement:
    return DatepickerElement(
        action_id="datepicker-vhs-event",
        placeholder=PlainTextObject("Date"),
        confirm=ConfirmObject(
            title=PlainTextObject(text="Confirmation"),
            text=PlainTextObject(text="Confirmation"),
            confirm=PlainTextObject(text="Confirm"),
            deny=PlainTextObject(text="Deny"),
        ),
    )
Пример #5
0
def button_element() -> ButtonElement:
    return ButtonElement(
        text="Login",
        action_id="17a",
        url="https://codededevils.org/cas/login/",
        value="Login",
        confirm=ConfirmObject(
            title=PlainTextObject(text="Confirmation"),
            text=PlainTextObject(text="Confirmation"),
            confirm=PlainTextObject(text="Confirm"),
            deny=PlainTextObject(text="Deny"),
        ),
    )
Пример #6
0
def context_block() -> ContextBlock:
    return ContextBlock(elements=[
        PlainTextInputElement(action_id="plaintext1",
                              placeholder=PlainTextObject(text="Context")),
        RadioButtonGroupElement(
            action_id="radiobutton1",
            options=[
                OptionObject(PlainTextObject(text="Radio button 1"),
                             value="radio1"),
                OptionObject(PlainTextObject(text="Radio button 2"),
                             value="radio2"),
            ],
        ),
    ])
Пример #7
0
def section_block() -> SectionBlock:
    return SectionBlock(
        text=PlainTextObject(text="Section"),
        fields=[
            TextObject(btype=TextObject.BTYPE_MARKDOWN, text="Section part 1"),
            TextObject(btype=TextObject.BTYPE_MARKDOWN, text="section part 2"),
            TextObject(btype=TextObject.BTYPE_MARKDOWN, text="section part 3"),
        ],
        accessory=ImageBlock(
            image_url="https://codedevils.org/static/img/logo.png",
            alt_text="Logo",
            title=PlainTextObject(text="Logo"),
        ),
    )
Пример #8
0
def option_object() -> OptionObject:
    option = str(random.randint(0, 10))
    return OptionObject(
        text=PlainTextObject(text="Option {}".format(option)),
        value=option,
        url="https://codedevils.org/{}".format(option),
    )
Пример #9
0
def view_payload() -> ViewPayload:
    return ViewPayload(
        btype=ViewPayload.BTYPE_HOME,
        title=TextObject(btype=TextObject.BTYPE_PLAINTEXT, text="Home page"),
        blocks=get_blocks(PlainTextObject(text="This block"), DividerBlock()),
        close=TextObject(btype=TextObject.BTYPE_PLAINTEXT, text="Close?"),
    )
Пример #10
0
def default_button_element() -> DefaultButtonElement:
    return DefaultButtonElement(
        text=PlainTextObject(text="Default button"),
        action_id="default-action-1002",
        url="https://codedevils.org/default",
        value="Default",
    )
Пример #11
0
def danger_button_element() -> DangerButtonElement:
    return DangerButtonElement(
        text=PlainTextObject(text="Danger button"),
        action_id="danger-action-1002",
        url="https://codedevils.org/danger",
        value="Danger",
    )
Пример #12
0
def primary_button_element() -> PrimaryButtonElement:
    return PrimaryButtonElement(
        text=PlainTextObject(text="Primary button"),
        action_id="primary-action-1002",
        url="https://codedevils.org/primary",
        value="Primary",
    )
Пример #13
0
def header_block() -> HeaderBlock:
    return HeaderBlock(text=PlainTextObject(text="This is a header block"),)
Пример #14
0
def option_group_object() -> OptionGroupObject:
    return OptionGroupObject(
        label=PlainTextObject(text="Option"), options=_get_options_list()
    )
Пример #15
0
def plain_text_object() -> PlainTextObject:
    return PlainTextObject(text="Plain text object")
Пример #16
0
def _get_options_list() -> typing.List[OptionObject]:
    return [
        OptionObject(text=PlainTextObject(text="Option"), value="Option")
        for _ in range(0, random.randint(3, 5))
    ]
Пример #17
0
def plaintext_input_element() -> PlainTextInputElement:
    return PlainTextInputElement(
        action_id="input-logo",
        placeholder=PlainTextObject(text="Input"),
        initial_value="Logo",
    )
Пример #18
0
def image_block() -> ImageBlock:
    return ImageBlock(
        image_url="https://codedevils.org/static/img/logo.png",
        alt_text="Logo",
        title=PlainTextObject(text="Logo"),
    )
Пример #19
0
def test_plain_text_object(plain_text_object: PlainTextObject):
    assert plain_text_object.render() == {
        "type": TextObject.BTYPE_PLAINTEXT,
        "text": plain_text_object.text,
        "emoji": plain_text_object.emoji
    }
Пример #20
0
def test_get_blocks():
    text1 = PlainTextObject(text="Text 1")
    text2 = PlainTextObject(text="Text 2")
    text3 = PlainTextObject(text="Text 3")
    blocks = get_blocks(text1, text2, text3)
    assert blocks == [text1.render(), text2.render(), text3.render()]