Skip to main content

Shared pytest fixtures (app, client, db_session, authenticated_client) for writing simple_module module tests

Project description

simple_module_test

Shared pytest fixtures and helpers for writing tests against simple_module apps and modules.

Fixtures are exposed via a pytest11 entry point, so installing the package is enough — no conftest.py import needed.

Install

pip install simple_module_test
# or, if you already pulled in the framework:
pip install "simple_module_hosting[dev]"

What it provides

  • settings — a ready-to-use Settings instance with an in-memory SQLite database and multi-tenancy enabled.
  • db_state, engine, db_session — fresh DatabaseState per test; db_session also creates all module tables and stamps alembic_version at head so the boot-time migration check passes.
  • app — a create_app(settings) instance with lifespan started and stopped.
  • client — an httpx.AsyncClient bound to the test app.
  • authenticated_client — same but with an admin user seeded and a forged session cookie attached.

Usage

In a module's tests/test_something.py:

import pytest

pytestmark = pytest.mark.asyncio


async def test_create_order(authenticated_client):
    resp = await authenticated_client.post(
        "/api/orders",
        json={"customer_id": 1, "total_cents": 9900},
    )
    assert resp.status_code == 201
    assert resp.json()["total_cents"] == 9900

No fixture imports, no conftest.py — the pytest11 entry point auto-loads them.

Depends on

  • simple_module_core, simple_module_db, simple_module_hosting
  • pytest, pytest-asyncio, httpx, sqlalchemy

License

MIT — see LICENSE.

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

simple_module_test-0.0.13.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

simple_module_test-0.0.13-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file simple_module_test-0.0.13.tar.gz.

File metadata

  • Download URL: simple_module_test-0.0.13.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for simple_module_test-0.0.13.tar.gz
Algorithm Hash digest
SHA256 cd17acb1bbb481575afbc58307b0e80bdbdaa9b933eadb1430ee0fb62ded4931
MD5 e1fa0878ace3f8d7f94b6f51ff8b79d8
BLAKE2b-256 196a25491aace194d88ece4a3b3359b48348c588c70ec5a73a8e3b5bedfeff86

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_test-0.0.13.tar.gz:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_module_test-0.0.13-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_module_test-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 ad19dedc5ebec40d84748392d0883be85017962d6b5105cd2241a9704c15280b
MD5 5f35ed7e543b5bafef8b22fca6b47937
BLAKE2b-256 0b491bc3dae07b707d4f9c3a64a6ef05e9c2686a389726c6d8ca7c9ac51c7533

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_test-0.0.13-py3-none-any.whl:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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