Pytest helpers for AMGI applications
Project description
pytest-amgi
Pytest helpers for driving AMGI applications in-process.
Installation
pip install pytest-amgi==0.41.1
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_amgi-0.41.1.tar.gz.
File metadata
- Download URL: pytest_amgi-0.41.1.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b588a4391b21505b8f42c885ddd3bb8611623c71abc2e4cbca7d44b85781c00
|
|
| MD5 |
ac4b233ffdbb73b1f6972f923b74f196
|
|
| BLAKE2b-256 |
c9dd4d98339137fdc069489b1fde4a2b31d74b216af630d150ebc71e71753e78
|
File details
Details for the file pytest_amgi-0.41.1-py3-none-any.whl.
File metadata
- Download URL: pytest_amgi-0.41.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce9f6ff73f210caa5ce8bd20f455491f23183daa21fb3ac5d7977947b96ee438
|
|
| MD5 |
75c496331cea1db13e975e4934c47264
|
|
| BLAKE2b-256 |
b966b736ca5af55c26f79687c1946db465f82958b0c076e1d28f298b4a85195d
|