Skip to main content

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, defer
  • message: 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

Metadata

Release files for interactions-unittest 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for interactions-unittest 1.0.3
File Size Uploaded
interactions_unittest-1.0.3.tar.gz 17.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for interactions-unittest 1.0.3
File Interpreter ABI Platform
interactions_unittest-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 34.7 kB

Release files / interactions_unittest-1.0.3.tar.gz

Download URL interactions_unittest-1.0.3.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
98d73093534f93653b8823f3786e3faea1c130a93fac1c3461d7452e3610326a
BLAKE2b-256 checksum
How to use checksums
2467d25962080f4685548441211edc83e618f45aa9921ae2d7683ce82e1a803f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.6

Release files / interactions_unittest-1.0.3-py3-none-any.whl

Download URL interactions_unittest-1.0.3-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2415a8e087869583a64f5dafd02cb55a9af5b9ca7fb1ee83ae730e05aaf1473
BLAKE2b-256 checksum
How to use checksums
cc5766532520671e14fd7c6001adf419c50071c329f0c9b949e4297ba29f4b52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.6

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page