Skip to content

Latest commit

 

History

History
95 lines (68 loc) · 3.38 KB

File metadata and controls

95 lines (68 loc) · 3.38 KB

Development

This document covers setting up a development environment and testing basics.

Topics

  1. Prerequisites
  2. Environment Setup
    1. With virtualenv
    2. With uv
    3. Visual Studio Code
  3. Unit Testing
  4. Integration Testing

Prerequisites

An installation of Python. My recommendation is to develop with a tool which supports environment isolation; some good choices include virtualenv, pyenv, uv, or conda; use what you're comfortable with.

Docker is required only if you plan to run integration tests with the Docker deployment. In this case, a Docker Python client will interface with the API to perform container actions for integration testing.

Environment Setup

Add developer dependencies (includes ruff, pytest and so on), and install "aio-lanraragi" in editable mode:

pip install -e ".[dev]"

With virtualenv

Install and test with virtualenv (Linux/MacOS):

virtualenv venv                 # create virtual environment at "venv"
source venv/bin/activate
pip install -e ".[dev]"
pytest tests/                   # run unit tests

Install with virtualenv (Windows):

virtualenv venv                 # create virtual environment at "venv"
.\venv\Scripts\activate
pip install -e ".[dev]"
pytest tests/                   # run unit tests

With uv

The project is a uv workspace. Install all packages (main library, integration tests, and dev extras) in one step:

uv sync --all-packages
uv run pytest tests/            # run unit tests

Visual Studio Code

The following advice applies to VS Code as well as its forks (Cursor, Codium, etc.).

You might want to install the usual VSCode Python extensions like Pylance, as well as ruff, then apply any of these settings as you wish to .vscode/settings.json:

{
    "python.analysis.autoImportCompletions": true,
    "python.analysis.autoFormatStrings": true,
    "python.analysis.extraPaths": [
        "integration_tests"
    ]
}

Additionally, VSCode supports workspaces, so it helps to create a workspace which includes both the LANraragi source code, as well as aio-lanraragi.

Architecture

Any request or response from LRRClient API calls must inherit the LanraragiRequest and LanraragiResponse class, respectively.

Unit Testing

Testing is mainly done with pytest.

pytest tests/                   # if you're using virtualenv
uv run pytest tests/            # if you're using uv

Note that when running uv, your current working directory matters, and the above command must be run at project root.

Resources should be carefully managed, and unclosed client sessions are a hard error, as configured into pytest in unit and integration tests.

Integration Testing

Integration testing is an important part of this client library, and it has its own supporting library (integration_tests), which is a workspace member. After running uv sync --all-packages at the project root, no additional install step is needed:

uv run pytest integration_tests/tests

For more info on integration testing, see integration_tests README.