Metadata-Version: 2.4
Name: simple_module_test
Version: 0.0.11
Summary: Shared pytest fixtures (app, client, db_session, authenticated_client) for writing simple_module module tests
Project-URL: Homepage, https://github.com/antosubash/simple_module_python
Project-URL: Repository, https://github.com/antosubash/simple_module_python
Project-URL: Issues, https://github.com/antosubash/simple_module_python/issues
Project-URL: Changelog, https://github.com/antosubash/simple_module_python/blob/main/CHANGELOG.md
Author-email: Anto Subash <antosubash@live.com>
License-Expression: MIT
License-File: LICENSE
Keywords: fixtures,pytest,pytest-plugin,simple-module,testing
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: FastAPI
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Testing
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: fastapi>=0.115
Requires-Dist: httpx>=0.27
Requires-Dist: pytest-asyncio>=0.24
Requires-Dist: pytest>=8.0
Requires-Dist: simple-module-core==0.0.11
Requires-Dist: simple-module-db==0.0.11
Requires-Dist: simple-module-hosting==0.0.11
Requires-Dist: sqlalchemy>=2.0
Description-Content-Type: text/markdown

# simple_module_test

Shared pytest fixtures and helpers for writing tests against [simple_module](https://github.com/antosubash/simple_module_python) apps and modules.

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

## Install

```bash
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`:

```python
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](https://github.com/antosubash/simple_module_python/blob/main/LICENSE).
