示例#1
0
def test_options_empty_base_command_group_options(command):
    command.name = "name"
    clazz = SlashCommand(command=command,
                         root=None,
                         name=None,
                         description="description",
                         options=[])
    clazz.append_options([Option(name="opt", description="desc")])
    assert clazz.options == [Option(name="opt", description="desc")]
示例#2
0
def test_to_dict(command):
    clazz = SlashCommand(command=command,
                         root="root",
                         name="name",
                         description="description",
                         options=[])
    assert clazz.to_dict() == {
        "name": clazz.name,
        "description": clazz.description,
        "options": [x.to_dict() for x in clazz.options]
    }
示例#3
0
def test_options_empty_base_command(command):
    command.name = "name"
    assert SlashCommand(command=command,
                        root=None,
                        name=None,
                        description="description",
                        options=[]).options == []
示例#4
0
def test_root_contains_whitespace_throws(command, root):
    with pytest.raises(ValueError):
        SlashCommand(command=command,
                     root=root,
                     name="name",
                     description="description",
                     options=[])
示例#5
0
def test_description_is_description(command):
    command.name = "command"
    assert SlashCommand(command=command,
                        root=None,
                        name=None,
                        description="description",
                        options=[]).description == "description"
示例#6
0
def test_name_contains_whitespace_throws(command, name):
    with pytest.raises(ValueError):
        SlashCommand(command=command,
                     root="root",
                     name=name,
                     description="description",
                     options=[])
示例#7
0
def test_options_list_base_command(command):
    command.name = "name"
    clazz = SlashCommand(command=command,
                         root=None,
                         name=None,
                         description="description",
                         options=[Option(name="opt", description="desc")])
    assert clazz.options == [Option(name="opt", description="desc")]
示例#8
0
def test_description_is_name(command):
    command.name = "name"
    command.description = None
    assert SlashCommand(command=command,
                        root=None,
                        name=None,
                        description=None,
                        options=[]).description == "name"
示例#9
0
def test_options_empty_root_command(command):
    assert SlashCommand(command=command,
                        root="root",
                        name="name",
                        description="description",
                        options=[]).options == [
                            SubCommand(name="name",
                                       description="description",
                                       type=OptionType.SUB_COMMAND,
                                       options=[])
                        ]
示例#10
0
def test_options_empty_root_command_group_options(command):
    clazz = SlashCommand(command=command,
                         root="root",
                         name="name",
                         description="description",
                         options=[])
    clazz.append_options([
        SubCommand(name="name2",
                   description="desc2",
                   type=OptionType.SUB_COMMAND,
                   options=[])
    ])
    assert clazz.options == [
        SubCommand(name="name",
                   description="description",
                   type=OptionType.SUB_COMMAND,
                   options=[]),
        SubCommand(name="name2",
                   description="desc2",
                   type=OptionType.SUB_COMMAND,
                   options=[]),
    ]
示例#11
0
def test_description_is_root(command):
    assert SlashCommand(command=command,
                        root="root",
                        name="name",
                        description="description",
                        options=[]).description == "root"