Skip to main content

Automate the testing of discord bots

Project description

Distest

A small library used to write automated test for Discord bots.

Bulk was written by DXsmiley, updated to the rewrite and modified a bit by me

Currently in pre-alpha, since I'm figuring out how this works. In addition to the example here, my main bot will be implementing this soon.

Installation

Best way to get this running is to git clone it.

Usage

In order to use this package, you'll have to create two bot accounts. The first, referred to as the target, is the bot that you wish to test. If you're already here you probably have a token for this bot already. The second one, called the tester is responsible for running the tests.

First, you need to run the bot that you wish to test. You can run the example bot supplied with this repo as follows:

python example_bot.py TARGET_TOKEN

Then, you have to run the tester bot:

python example_tester.py TARGET_USERNAME TESTER_TOKEN

Make sure to use the username of the bot without the discriminator (#1111) or the bot won't understand what the user is

Once both bots are running, go to any discord channel that both bots have access to and type ::run all to run all the tests. Use ::help to get more information on the commands that the tester bot takes.

Options

Commands you can run in discord once the bot is up.

::stats
    Gives details about which tests have been
    run and what the results were

::run test_name
    Run a particular test

::run all
    Run all tests

::run unrun
    Run all tests that have not yet been run

::run failed
    Run all tests that failed on the most recent run

New Tests

I'm still figuring this part out, but it seems that you write tests in the testing bot and decorate them with an instance of distest.TestCollector(). Then, you can run the bot and use the run commands to run the tests.

TODO

  • Update the Bot to the newly re-written discord.py 1.0
  • Test each test
    • send_message
    • edit_message
    • wait_for_reaction
    • wait_for_message
    • wait_for_reply
    • assert_message_equals
    • assert_message_contains
    • assert_message_matches
    • assert_reply_equals
    • assert_reply_contains
    • assert_reply_matches
    • assert_reaction_equals
    • ensure_silence
    • ask_human
  • Allow running tests from the command line

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

distest-0.1.0.dev0.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

distest-0.1.0.dev0-py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page