Pytest plugin that fails your tests when ORM queries cross DDD aggregate boundaries (Django supported today).
Project description
pytest-orm-boundaries
A pytest plugin that fails your tests when ORM queries cross your DDD aggregate boundaries.
Currently works with Django ORM.
In domain-driven design, an aggregate is a consistency boundary: code in one
aggregate should not reach into the internals of another. Django's __ relation
lookups make it easy to cross those boundaries silently:
# Payment and Order belong to different aggregates — this query couples them.
Purchase.objects.get(client__name="John")
pytest-orm-boundaries watches the queries your test suite executes and
reports the ones that step outside their aggregate, including __, subqueries and other.
Install
pip install pytest-orm-boundaries
pytest picks the plugin up automatically.
Configure
Declare your aggregates in boundaries.toml at the project root (or point at
the file with --boundaries-config / the boundaries_config ini option):
[aggregates]
client = ["bookshop.Client"]
book = ["bookshop.Book"]
purchase = ["bookshop.Purchase", "bookshop.PurchaseLine"]
Models are written as app_label.Model. Models not listed in any aggregate are
not checked. Without a config file the plugin emits a warning and runs no checks.
Status
Alpha - testing basic version.
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_orm_boundaries-0.1.0.tar.gz.
File metadata
- Download URL: pytest_orm_boundaries-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0905203d5a690390b77036002998d3577a0b093c18412dbfbf8773a87d5a9be9
|
|
| MD5 |
0fb414d338b458bcc9b7eb3da5c161d2
|
|
| BLAKE2b-256 |
cd2cf864e5a402c63c9fed58124400d4bbd4a877f3e051d23e2c0ce62e041e27
|
File details
Details for the file pytest_orm_boundaries-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pytest_orm_boundaries-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a80ca7047f9fe0b13d7974e0399d48604f8b587e430c43a20774808449dcae0a
|
|
| MD5 |
83894bc04d1c9d76f09c33fd89252e9d
|
|
| BLAKE2b-256 |
67adae008d12aeac4abdb01b121919fae714a4682fe96f54cf373b27e84a3557
|