Whitesmith
Test helper for blacksmith resources.
Motivation
Whitesmith is the swissknife for developping and testing code base that use [[https://](https://github.com/mardiros/blacksmith](blacksmith).
While using blacksmith, resources are declared using pydantic, and, while testing, we never do http calls.
Whitesmith is a helper that create pytest fixtures with handlers for tests, client types and generate documentation for blacksmith resources and .
Usage
Generating typed client
The command bellow will create a file blacksmith_client.py in the codebase
that override the blacksmith client factory to get a fully typed client.
whitesmith generate-types -m my_package.resources -o my_package/resources/blacksmith_client.py
Use --overwrite if the file exists and you want to regenerate it.
Now, you can import the AsyncAppClientFactory or SyncAppClientFactory
to get a fully typed client and not import blacksmith module anywhere from the codebase.
Generating fixtures
The command below will generate a folder tests/whitesmith containing
handlers for all the api call with a default implementation.
whitesmith generate-handlers -m my_package.resources --out-dir tests/
Note If you run the command again, the command does not overwrite generated files. To generate a newer version, use the
--overwriteflag.
Those fixtures can be adapted to get the result you want, they must be present in a whitesmith_handlers directory inside the tests suite.
Using the fixtures
The whitesmith package provide three pytest fixtures that can be used in the testsuite.
The fixtures sync_blacksmith_client, async_blacksmith_client can be used to get
a blacksmith client instance that use the installed fixtures from the generated
directory.
Both actually consume the undelying fixtures whitesmith_router is a generated
fixture that contains all the routes contained inside a whitesmith_handlers directory.
This directory is the one created by the commande above whitesmith generate-handlers.
You can have multiple whitesmith_handlers by creating tests submodules
to handle mulptiple behavior when its needed.
Building a client contract (open api format)
This feature is a bit experimental but was the main motivation of blacksmith, provide a tool for consumer-driven contract (CDC) so generated document of client contract is nice to have. A tool to ensure server and client contract compatibility could be used to enforce maintainability.
uv run whitesmith generate-openapi -m my_package.resources -o docs/resources/openapis --overwrite
cd docs/resources/openapis
python -m http.server 8000
Metadata
Release files for whitesmith 6.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| whitesmith-6.0.0.tar.gz | 15.3 kB | Without provenance | Details for whitesmith-6.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| whitesmith-6.0.0-py3-none-any.whl | Python 3 | none | any | Details for whitesmith-6.0.0-py3-none-any.whl |
Total release size: 34.2 kB
Release files / whitesmith-6.0.0.tar.gz
| Download URL | whitesmith-6.0.0.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d5d7677f57dd0ced2066118b5022f28999f0e140ca0a158f1542da415a3bd1c
|
|
BLAKE2b-256 checksum How to use checksums |
6897d82fffab95ed298b2e9271052ee4e8ba1b823a5b078e602c1726ea84d7e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.29.7 CPython/3.13.18 Linux/7.0.0-1020-azure
|
Release files / whitesmith-6.0.0-py3-none-any.whl
| Download URL | whitesmith-6.0.0-py3-none-any.whl |
|---|---|
| Size | 18.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10cfcf924b6ffe3d6bf12d3956cc31dae4761bd122613c0e528f58b914948c3f
|
|
BLAKE2b-256 checksum How to use checksums |
e2b4c47518d55a0b170d222d23a80d69fd0172d24453fbebd0d38242158fb074
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.29.7 CPython/3.13.18 Linux/7.0.0-1020-azure
|
Security for whitesmith 6.0.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.