Ejemplo n.º 1
0
def test_create_fail_if_command_name_empty(client):
    error_message = "Field may not be empty."
    with pytest.raises(ValidationError, match=error_message):
        update_command_processor(
            user_id=user_id,
            team_id=team_id,
            channel_id=channel_id,
            command_to_update="",
        )
Ejemplo n.º 2
0
def test_create_fail_if_pick_list_is_None(client):
    error_message = "Field may not be null."
    with pytest.raises(ValidationError, match=error_message):
        update_command_processor(
            user_id=user_id,
            team_id=team_id,
            channel_id=channel_id,
            command_to_update=command_name,
            pick_list=None,
        )
Ejemplo n.º 3
0
def test_update_fail_if_command_does_not_exist(client):
    with pytest.raises(
        MissingElementError, match="Command test_update does not exist."
    ):
        update_command_processor(
            user_id=user_id,
            team_id=team_id,
            channel_id=channel_id,
            command_to_update=command_name,
        )
Ejemplo n.º 4
0
def test_create_fail_if_non_valid_strategy(client):
    error_message = "boop is not a valid strategy."
    with pytest.raises(ValidationError, match=error_message):
        update_command_processor(
            user_id=user_id,
            team_id=team_id,
            channel_id=channel_id,
            new_command_name=command_name,
            strategy="boop",
            pick_list=default_pick_list,
        )
Ejemplo n.º 5
0
def test_update(
    input_data, expected_command, expected_message, non_expected_message, client
):
    Command.create(**default_expected_command)
    response = update_command_processor(
        user_id=user_id,
        team_id=team_id,
        channel_id=channel_id,
        command_to_update=command_name,
        **input_data,
    )

    message = response.get("message")

    if expected_message:
        assert expected_message in message.content
    if non_expected_message:
        assert non_expected_message not in message.content
    assert message.status == MessageStatus.INFO
    assert message.visibility == MessageVisibility.NORMAL

    updated_command = (
        Command.find_one_by_name_and_chanel(name=command_name, channel_id=channel_id)
        .to_son()
        .to_dict()
    )

    for key in expected_command:
        assert updated_command[key] == expected_command[key]