Add a text class using pytest
This commit is contained in:
parent
fe16c3f85d
commit
5693751c0a
2 changed files with 24 additions and 2 deletions
|
@ -134,5 +134,6 @@ def group_to_message(group: list[discord.Member]) -> str:
|
|||
return f"Matched up {mentions}!"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
handler = logging.StreamHandler()
|
||||
bot.run(config.TOKEN, log_handler=handler, root_logger=True)
|
||||
|
|
21
matchy_test.py
Normal file
21
matchy_test.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
"""
|
||||
Test functions for Matchy
|
||||
"""
|
||||
import discord
|
||||
import pytest
|
||||
import matchy
|
||||
|
||||
|
||||
@pytest.mark.parametrize("matchees, per_group", [
|
||||
([discord.Member.__new__(discord.Member)] * 100, 3),
|
||||
([discord.Member.__new__(discord.Member)] * 12, 5),
|
||||
([discord.Member.__new__(discord.Member)] * 11, 2),
|
||||
([discord.Member.__new__(discord.Member)] * 356, 8),
|
||||
])
|
||||
def test_matchees_to_groups(matchees, per_group):
|
||||
"""Test simple group matching works"""
|
||||
groups = matchy.matchees_to_groups(matchees, per_group)
|
||||
for group in groups:
|
||||
# Ensure the group contains the right number of members
|
||||
assert len(group) >= per_group
|
||||
assert len(group) < per_group*2
|
Loading…
Add table
Reference in a new issue