Skip to main content

pytest-arrakis

Pytest plugin providing Arrakis fixtures for testing

pypi version


Resources

Installation

pip install pytest-arrakis

To enable publish fixtures (including a real Kafka-backed server), install the publish extra:

pip install pytest-arrakis[publish]

Fixtures

Core fixtures

These are available out of the box:

Fixture Scope Description
arrakis_channel_configs session List of paths to the bundled per-publisher config files
arrakis_backend session A MockBackend configured with all bundled channels (regular and replay)
arrakis_server session A running mock ArrakisFlightServer with a replay registry (sets ARRAKIS_SERVER env var)
arrakis_channels session Dict of channel metadata loaded from the bundled TOML (regular channels only)
arrakis_mock_publisher function A mocked Publisher with FakeProducer for sink testing (no server/broker needed)

Replay fixtures

These provide replay-specific resources for testing replay functionality:

Fixture Scope Description
arrakis_replay_channel_configs session List of paths to the bundled replay publisher config files
arrakis_replay_params session A ReplayParams for the bundled FAKE_REPLAY window (fixed 24-hour period)
arrakis_replay_channels session Dict of channel metadata from the replay configs only
arrakis_replay_mock_publisher function A mocked replay Publisher with FakeProducer for sink testing

Publish fixtures (requires publish extra)

These are conditionally registered when arrakis-backend-kafka and pytest-kafka-broker are installed:

Fixture Scope Description
arrakis_publish_backend function A real KafkaBackend pointed at an embedded Kafka broker (includes replay configs)
arrakis_publish_server function A publish-capable ArrakisFlightServer with a replay registry
arrakis_publisher function A real Publisher registered against the embedded broker
arrakis_replay_publisher function A real Publisher for the replay namespace against the embedded broker

Usage

Fetching data from a mock server

def test_fetch(arrakis_server):
    import arrakis

    block = arrakis.fetch(["H1:TEST-CHANNEL_SIN"], 0, 1)
    for channel, series in block.items():
        assert len(series) > 0

Testing a publisher without a real broker

def test_publish(arrakis_mock_publisher):
    publisher, fake_producer, published_blocks = arrakis_mock_publisher

    # publish a block through your code under test ...
    assert len(published_blocks) == 1

End-to-end publish testing (requires publish extra)

def test_roundtrip(arrakis_publisher):
    # arrakis_publisher is a real Publisher connected to an embedded Kafka broker
    ...

Testing replay channel discovery

def test_replay_find(arrakis_server, arrakis_replay_params):
    from arrakis import Client

    client = Client(arrakis_server.url)
    # replay channels are only visible when querying with the replay ID
    replay_channels = list(client.find(replay_id="FAKE_REPLAY"))
    assert len(replay_channels) > 0

Testing a replay publisher without a real broker

def test_replay_publish(arrakis_replay_mock_publisher):
    publisher, fake_producer, published_blocks = arrakis_replay_mock_publisher

    # publish a block through your code under test ...
    assert len(published_blocks) == 1

Bundled test channels

The plugin ships with a set of test channel definitions:

Regular channels

Channel Publisher Sample Rate Data Type
H1:TEST-CHANNEL_SIN FAKE_H1 512 float32
H1:TEST-CHANNEL_COS FAKE_H1 16384 float64
H1:TEST-STATE_ONES FAKE_H1 16 int32
L1:TEST-NOISE FAKE_L1 4096 float32

Replay channels

These are tagged with replay_id = "FAKE_REPLAY" and are only visible when querying with the corresponding replay ID:

Channel Publisher Sample Rate Data Type
H1:REPLAY-CHANNEL_SIN FAKE_REPLAY_H1 512 float32
H1:REPLAY-STATE_ONES FAKE_REPLAY_H1 16 int32

CI setup

GitLab CI

The core fixtures work without any extra system dependencies. However, the publish extra uses pytest-kafka-broker, which starts an embedded Kafka broker that requires a JVM at runtime. In Debian/Ubuntu-based CI images (including the standard python: Docker images), install it in a before_script:

test:
  image: python:3.13
  before_script:
    - apt-get update && apt-get install -y --no-install-recommends default-jre-headless

If you only use the core fixtures (no publish extra), the JVM is not needed.

Metadata

Release files for pytest-arrakis 0.6.0

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

Source distribution (sdist)

Source distribution for pytest-arrakis 0.6.0
File Size Uploaded Provenance Actions
pytest_arrakis-0.6.0.tar.gz 10.8 kB Without provenance Details for pytest_arrakis-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-arrakis 0.6.0
File Interpreter ABI Platform Actions
pytest_arrakis-0.6.0-py3-none-any.whl Python 3 none any Details for pytest_arrakis-0.6.0-py3-none-any.whl

Total release size: 25.6 kB

Release files / pytest_arrakis-0.6.0.tar.gz

Download URL pytest_arrakis-0.6.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
856ad7645a4a968a84dbb3aa201bbc18706dc7530079b8b65aef1cd57e3b65bf
BLAKE2b-256 checksum
How to use checksums
95ff8c2661b70ff0a3f41ec4afc2d840c384042a15019df74c9110eb23ff9cb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.13.12 HTTPX/0.28.1

Release files / pytest_arrakis-0.6.0-py3-none-any.whl

Download URL pytest_arrakis-0.6.0-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8351abdf7d861d21adef85957e601b8ebbc5570a842ea214728e52d7ae28fd79
BLAKE2b-256 checksum
How to use checksums
c544956548daa0d0c8da79efa7a3d2c6a1e0a8bce7bd9ec158dde55efe7db70e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.13.12 HTTPX/0.28.1

Security for pytest-arrakis 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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