Skip to content

Uninett/pytest-argus-server

Repository files navigation

pytest-argus-server

PyPI version Python versions See Build Status on GitHub Actions

A pytest plugin that provides a running Argus API server for tests.


This pytest plugin was generated with Cookiecutter along with @hackebrot's cookiecutter-pytest-plugin template.

Features

  • Fixtures that will provide tests with a running Argus API server (using Docker Compose)

Requirements

Installation

You can install "pytest-argus-server" via pip from PyPI:

$ pip install pytest-argus-server

Usage

Installing this package will automatically make it available in pytest.

Extra pytest command line arguments

By default, this plugin will run the latest available Argus server Docker image. The actually deployed version can be controlled by adding the --argus-version command line option to pytest:

pytest --argus-version=1.30.0 tests/

Provided fixtures

The main fixtures provided by this plugin are the session-scoped argus_api_url and argus_source_system_token.

argus_api_url

When used by a test, this will ensure an Argus server is running and ready to take requests. It returns the base URL of the running API:

def test_url_should_be_as_expected(argus_api_url):
    assert argus_api_url == "http://localhost:8000/api/v2/"

argus_source_system_token

This token will create a test source system and return a valid API token for accessing the API as this test source.

def test_fetch_incidents(argus_api_url, argus_source_system_token):
    assert requests.get(
        f"{argus_api_url}/incidents/",
        headers={"Authorization": f"Token {argus_source_system_token}"}
    ).status_code == 200

Bugs

  • The port number of the launched API server is hard-coded to 8000.

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the Apache Software License 2.0 license, "pytest-argus-server" is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

About

A pytest plugin that provides a running Argus API server for tests

Resources

License

Stars

Watchers

Forks