Unofficial unittest extension for discord-py-interactions
Project description
About
This package allows you to test you discord bot's commands without having to run the bot itself. It is made to be a drop-in library to be used with unittest or pytest.
Installation
pip install interactions-unittest
Usage
import unittest
import interactions
import interactions_unittest as itest
@interactions.SlashCommand(
name="ping",
description="Replies with pong",
options=[
interactions.Option(
name="extra",
description="extra text",
type=interactions.OptionType.STRING,
required=False
)
]
)
async def ping(ctx: interactions.SlashContext, extra: str = None):
await ctx.send(f"Pong! {extra}")
class TestPing(unittest.IsolatedAsyncioTestCase):
async def test_ping(self):
actions = await itest.call_slash(ping, extra="extra text")
self.assertTrue(actions[0]["action"] == "send")
self.assertTrue(actions[0]["message"]["content"] == "Pong! extra text")
Documentation
The call_slash method allows you to call a slash command with arguments, it will return a list of action dicts.
Each action dict has the following keys:
action: The action that was performed, ex:send,edit,delete,defermessage: The message that was sent, edited or deleted
Features
- context.edit message
- context.delete message
- context.send message
- context.defer
- message.delete
- message.edit
- message.reply
- message.react
- extensions
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file interactions_unittest-1.0.3.tar.gz.
File metadata
- Download URL: interactions_unittest-1.0.3.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98d73093534f93653b8823f3786e3faea1c130a93fac1c3461d7452e3610326a
|
|
| MD5 |
d22c64192447746be54c757ca2a960ae
|
|
| BLAKE2b-256 |
2467d25962080f4685548441211edc83e618f45aa9921ae2d7683ce82e1a803f
|
File details
Details for the file interactions_unittest-1.0.3-py3-none-any.whl.
File metadata
- Download URL: interactions_unittest-1.0.3-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2415a8e087869583a64f5dafd02cb55a9af5b9ca7fb1ee83ae730e05aaf1473
|
|
| MD5 |
25243b26342063508450eb198ce247d0
|
|
| BLAKE2b-256 |
cc5766532520671e14fd7c6001adf419c50071c329f0c9b949e4297ba29f4b52
|