Bot¶
Contains the discord clients used to run tests.
DiscordBot
contains the logic for running tests and finding the target bot
DiscordInteractiveInterface
is a subclass of DiscordBot
and contains the logic to handle
commands sent from discord to run tests, display stats, and more
DiscordCliInterface
is a subclass of DiscordInteractiveInterface
and simply contains logic to
start the bot when it wakes up
-
class
distest.bot.
DiscordBot
(target_id)[source]¶ Discord bot used to run tests. This class by itself does not provide any useful methods for human interaction, and is just used as a superclass of the two interfaces,
DiscordInteractiveInterface
andDiscordCliInterface
- Parameters
target_id (str) – The name of the target bot, used to ensure that the target user is actually present in the server. Good for checking for typos or other simple mistakes.
-
async
run_test
(test, channel, stop_error=False)[source]¶ Run a single test in a given channel.
Updates the test with the result and returns it
- Parameters
channel (discord.TextChannel) – The
stop_error – Weather or not to stop the program on error. Not currently in use.
- Returns
Result of the test
- Return type
-
class
distest.bot.
DiscordInteractiveInterface
(target_id, collector, timeout=5)[source]¶ A variant of the discord bot which commands sent in discord to allow a human to run the tests manually.
Does NOT support CLI arguments
- Parameters
target_id (str) – The name of the bot to target (Username, no discriminator)
collector (TestCollector) – The instance of Test Collector that contains the tests to run
timeout (int) – The amount of time to wait for responses before failing tests.
-
async
on_message
(message)[source]¶ Handle an incoming message, see
discord.event.on_message()
for event reference.Parse a message, can ignore it or parse the message as a command and run some tests or do one of the alternate functions (stats, list, or help)
- Parameters
message (discord.Message) – The message being recieved, passed by discord.py
-
async
on_ready
()[source]¶ Report when the bot is ready for use and report the available tests to the console
-
async
run_tests
(channel, name)[source]¶ Helper function for choosing and running an appropriate suite of tests Makes sure only tests that still need to be run are run, also prints to the console when a test is run
- Parameters
channel (discord.TextChannel) – The channel in which to run the tests
name (str) – Selector string used to determine what category of test to run
-
class
distest.bot.
DiscordCliInterface
(target_id, collector, test, channel_id, stats, timeout)[source]¶ A variant of the discord bot which is designed to be run off command line arguments.
- Parameters
target_id (str) – The name of the bot to target (Username, no discriminator)
collector (TestCollector) – The instance of Test Collector that contains the tests to run
test (str) – The name of the test option (all, specific test, etc)
channel_id (int) – The ID of the channel to run the bot in
stats (bool) – If true, run in hstats mode.
-
async
on_ready
()[source]¶ Run all the tests sequentially when the bot becomes awake and exit when the tests finish. The CLI should run all by itself without prompting, and this allows it to behave that way.