Skip to content

Feature: Add pytest testing framework and CI workflow #186

@RemainingDelta

Description

@RemainingDelta

Overview

Introduce pytest with pytest-asyncio as the project's testing foundation, along with a GitHub Actions workflow that runs tests on PRs. This gives contributors a
structured way to verify behavior without a live bot and catches regressions before they merge.

Technical Requirements

  • Add pytest and pytest-asyncio as dev dependencies (requirements-dev.txt or extras)
  • Create tests/conftest.py with shared mock fixtures for bot instance (discord.ext.commands.Bot), MongoDB/Motor collections, and Discord context/interaction
    objects
  • Add at least one sample async test as a template for future contributors
  • Add .github/workflows/tests.yml that triggers on PRs to dev and main, runs pytest with no real secrets required, and runs in parallel with the existing
    Ruff workflow

Acceptance Criteria

  • pytest and pytest-asyncio are installed and configured (pyproject.toml or pytest.ini)
  • tests/conftest.py provides reusable fixtures for bot, MongoDB, and Discord context
  • CI runs pytest on every PR without DISCORD_TOKEN or MONGO_URI
  • Existing Ruff workflow is unaffected
  • At least one passing async test exists

Notes

BOT_MODE=TEST can be set in the CI environment without a real token since nothing connects to Discord. Use unittest.mock.AsyncMock for Motor and Discord async
interfaces.

Branch

186-Feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureSomething to add/change to the bot

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions