示例#1
0
def test_lock_toggle(kudos: ChatKudos, message: Mock) -> None:
    """Turn the lock on and off again, fixture starts locked"""
    message.content = "kudos!lock"

    result = kudos.parse_command(message)
    assert result == "ChatKudos is now unlocked. **Everyone** can use it!"
    assert not kudos.get_guild("111").lock

    result = kudos.parse_command(message)
    assert result == "ChatKudos is now locked. Only allowed users/roles can use it!"
    assert kudos.get_guild("111").lock
示例#2
0
def test_adjust_loss_messages(kudos: ChatKudos, message: Mock) -> None:
    """Adjust the loss messages on existing and non-existing guilds"""
    message.content = "kudos!loss This is loss"
    result = kudos.parse_command(message)
    assert "Message has been set." in result
    assert kudos.get_guild("111").loss_message == "This is loss"

    message.guild.id = "999"
    result = kudos.parse_command(message)
    assert "Message has been set." in result
    assert kudos.get_guild("999").loss_message == "This is loss"
示例#3
0
def test_add_remove_role_list(kudos: ChatKudos, message: Mock) -> None:
    """Add, then remove, a role from role list"""
    message.mentions = []  # Clear to focus test scope
    message.content = "kudos!role @Cool Kats"  # role_mention provided by fixture

    result = kudos.parse_command(message)
    assert "**+**Cool Kats" in result
    assert "987" in kudos.get_guild("111").roles

    result = kudos.parse_command(message)
    assert "**-**Cool Kats" in result
    assert "987" not in kudos.get_guild("111").roles
示例#4
0
def test_add_remove_user_list(kudos: ChatKudos, message: Mock) -> None:
    """Add, then remove, a user from user list"""
    message.role_mentions = []  # Clear to focus test scope
    message.content = "kudos!user @Tester"  # mention is provided by fixture

    result = kudos.parse_command(message)
    assert "**+**Tester" in result
    assert "111" in kudos.get_guild("111").users

    result = kudos.parse_command(message)
    assert "**-**Tester" in result
    assert "111" not in kudos.get_guild("111").users
示例#5
0
def test_adjust_max(kudos: ChatKudos, message: Mock) -> None:
    """Change max for existing and non-existing guild"""
    message.content = "kudos!max 10"
    result = kudos.parse_command(message)
    assert "Max points now: 10" in result

    message.content = "kudos!max -1"
    message.guild.id = "999"
    result = kudos.parse_command(message)
    assert "Max points now: unlimited" in result

    assert kudos.get_guild("111").max == 10
    assert kudos.get_guild("999").max == -1
示例#6
0
def test_board_limited(kudos: ChatKudos, message: Mock) -> None:
    """Print the board with a # limit"""
    message.content = "kudos!board 1"

    result = kudos.parse_command(message)
    assert "Top 1 ChatKudos holders:" in result
    assert "Tester01" in result
    assert "Tester02" not in result
示例#7
0
def test_board_all(kudos: ChatKudos, message: Mock) -> None:
    """Print the board without # limit"""
    message.content = "kudos!board Give me all the board"

    result = kudos.parse_command(message)
    assert "Top 10 ChatKudos holders:" in result
    assert "Tester01" in result
    assert "Tester02" in result
示例#8
0
def test_add_remove_list_empty(kudos: ChatKudos, message: Mock) -> None:
    """Confirm message with no mentions is skipped"""
    message.role_mentions = []
    message.mentions = []
    message.content = "kudos!user This is just an empty message"

    result = kudos.parse_command(message)
    assert not result
示例#9
0
def test_help(kudos: ChatKudos, message: Mock) -> None:
    """Does this have a help?"""
    message.content = "kudos!help"

    result = kudos.parse_command(message)
    assert "https://github.com/Preocts/eggbot/blob/main/docs/chatkudos.md" in result
示例#10
0
def test_adjust_message_empty(kudos: ChatKudos, message: Mock) -> None:
    """Confirm an empty message is skipped"""
    message.content = "kudos!gain"
    result = kudos.parse_command(message)
    assert not result
示例#11
0
def test_adjust_max_invalid(kudos: ChatKudos, message: Mock) -> None:
    """Provide an invalid format to the command"""
    message.content = "kudos!max 10 points"
    result = kudos.parse_command(message)
    assert "Usage:" in result