Skip to content

Run tests

OpenGateLLM uses a combination of unit and integration tests to ensure the quality of the code.

  • Directoryapi/
    • Directorytests/
      • Directoryunit/
      • Directoryintegration/

Unit tests are located in the tests/unit folder. They are written using the pytest framework.

  1. Create a Python virtual environment (recommended)

  2. Install the dependencies with the following command:

    Terminal window
    pip install ".[api,test]"
  3. To run the tests, you can use the following command:

    Terminal window
    make test-unit

Integration tests are located in the tests/integration folder. They are written using the pytest framework and Docker compose to run the API and its dependencies in Docker containers.

  1. Create a Python virtual environment (recommended)

  2. Install the dependencies with the following command:

    Terminal window
    pip install ".[api,test]"
  3. To run the tests, you can use the following command:

    Terminal window
    make test-integration

To run the tests with VSCode, you can create a .vscode/settings.json file with the following content:

{
"python.terminal.activateEnvironment": true,
"python.testing.pytestArgs": [
"api", "-s", "--config-file=pyproject.toml"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.envFile": "${workspaceFolder}/.github/.env.ci"
}