ulfblk-testing
Shared testing utilities and pytest fixtures for the Bloques ecosystem.
Installation
# Base (HTTP client factories + settings helpers)
uv add --dev ulfblk-testing
# With JWT auth fixtures
uv add --dev "ulfblk-testing[auth]"
# With database fixtures
uv add --dev "ulfblk-testing[db]"
# Everything
uv add --dev "ulfblk-testing[all]"
Auto-registered Fixtures (pytest plugin)
When installed, these fixtures are automatically available in your tests:
| Fixture | Requires | Scope | Description |
|---|---|---|---|
test_app |
base | function | Minimal FastAPI app with /ping endpoint |
test_client |
base | function | AsyncClient bound to test_app |
rsa_keys |
[auth] |
session | RSA key pair (private_pem, public_pem) |
jwt_manager |
[auth] |
function | JWTManager with test RSA keys |
test_engine |
[db] |
function | SQLite in-memory AsyncEngine |
test_session_factory |
[db] |
function | async_sessionmaker bound to engine |
Helper Functions
HTTP Clients
from ulfblk_testing import create_test_client, create_authenticated_client
# Basic client
async with create_test_client(app) as client:
resp = await client.get("/health")
# Authenticated client
token = create_test_token(jwt_manager)
async with create_authenticated_client(app, token) as client:
resp = await client.get("/protected")
JWT Auth ([auth] extra)
from ulfblk_testing import generate_rsa_keys, create_jwt_manager, create_test_token
# Generate keys + manager
private_pem, public_pem = generate_rsa_keys()
manager = create_jwt_manager(private_pem, public_pem)
# Or auto-generate keys
manager = create_jwt_manager()
# Create test tokens with defaults
token = create_test_token(manager, user_id="u-1", tenant_id="t-1", roles=["admin"])
Database ([db] extra)
from ulfblk_testing import create_test_engine, create_test_session_factory, create_tables
engine = create_test_engine()
session_factory = create_test_session_factory(engine)
await create_tables(engine, Base)
async with session_factory() as session:
# your test queries
pass
Settings
from ulfblk_testing import create_test_settings, override_settings
from ulfblk_core import BloqueSettings
# Create settings with overrides
settings = create_test_settings(BloqueSettings, debug=True)
# Temporarily patch a settings object
with override_settings("myapp.config.settings", BloqueSettings, debug=True):
# settings patched here
pass
Metadata
Release files for ulfblk-testing 0.1.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 | |
|---|---|---|---|
| ulfblk_testing-0.1.0.tar.gz | 7.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ulfblk_testing-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.7 kB
Release files / ulfblk_testing-0.1.0.tar.gz
| Download URL | ulfblk_testing-0.1.0.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cbc7a8d844abb3904b383232fe8b4b34571238bdab2db88f494bef6a7271c225
|
|
BLAKE2b-256 checksum How to use checksums |
efc533be9c2531e02bd980f194bbcafc743997eaf334c1b64e95c9a7a9afa2b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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":null}
|
Release files / ulfblk_testing-0.1.0-py3-none-any.whl
| Download URL | ulfblk_testing-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b7f661e4ea0faad2f8b2291c4880cbfd52a10207cd508da770904cc934a3cc1a
|
|
BLAKE2b-256 checksum How to use checksums |
878004d0fc0c7514573404289c4c23d641ea5296355df4f1ebef8153922ed286
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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":null}
|