Skip to main content

Pytest helpers for AMGI applications

Project description

pytest-amgi

Pytest helpers for driving AMGI applications in-process.

Installation

pip install pytest-amgi==0.42.0

Example

This example uses AsyncFast:

from asyncfast import AsyncFast
from pytest_amgi import AMGIProducerFactory


async def test_message(amgi_producer: AMGIProducerFactory) -> None:
    app = AsyncFast()

    @app.channel("topic")
    async def handler(payload: int) -> None:
        assert payload == 1

    producer = await amgi_producer(app)
    response = await producer.send("topic", json=1)

    response.assert_acked()

The amgi_producer fixture starts lifespan before returning the producer and shuts it down when the test finishes.

Message Sends

Use assert_has_message_send to assert that the application sent a follow-up message:

from dataclasses import dataclass

from asyncfast import AsyncFast
from asyncfast import Message
from asyncfast import MessageSender
from pytest_amgi import AMGIProducerFactory


@dataclass
class ProcessOrder(Message, address="order.process"):
    payload: dict[str, int]


async def test_message_send(amgi_producer: AMGIProducerFactory) -> None:
    app = AsyncFast()

    @app.channel("order.created")
    async def handle_order_created(
        message_sender: MessageSender[ProcessOrder],
    ) -> None:
        await message_sender.send(ProcessOrder(payload={"id": 1}))

    producer = await amgi_producer(app)
    response = await producer.send("order.created")

    response.assert_acked()
    response.assert_has_message_send("order.process", json={"id": 1})

Contact

For questions or suggestions, please contact jack.burridge@mail.com.

License

Copyright 2026 AMGI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_amgi-0.42.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_amgi-0.42.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest_amgi-0.42.0.tar.gz.

File metadata

  • Download URL: pytest_amgi-0.42.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pytest_amgi-0.42.0.tar.gz
Algorithm Hash digest
SHA256 029b65c0b25318d6989dfd5c96111f63b9b4289816efa22d19bf233a7a1c4b1e
MD5 6a2003afaa9e0adbc6b09b9b72a56766
BLAKE2b-256 d56cbaf183bdd8e23f2f6e5862cc7f23d3ad38cdc1b58ff0efc7e1e44629ef03

See more details on using hashes here.

File details

Details for the file pytest_amgi-0.42.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_amgi-0.42.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pytest_amgi-0.42.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57852863f64983c7a71a5249c8966d2fe03d96c86d9994c7b014ec71fb70833c
MD5 50baf164ef52c39677e9bb29b409b5a0
BLAKE2b-256 3e2f1bf4c4090f4721a759c1b0b8c8d01bda5dba1fe094e64e0d7a90a489b139

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page